
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>地图区域</title>
<style type="text/css">
	body, html,#map {width:100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
    #district-search-tip {
        background-color:#fff;
        padding:0 10px;
        border:1px solid silver;
        box-shadow:3px 4px 3px 0px silver;
        position:absolute;
        font-size:12px;
        right:20px;
        top: 5px;
        border-radius: 3px;
        line-height: 36px;
    }
</style>
<link rel="stylesheet" type="text/css"  href="/styles/common.css" >
<link rel="stylesheet" type="text/css"  href="/styles/jquery-easyui-themes/gray/easyui.css">
<link rel="stylesheet" type="text/css"  href="/styles/jquery-easyui-themes/icon.css">
<script type="text/javascript" src="/scripts/jquery/jquery-1.8.2.min.js"></script>
<SCRIPT type="text/javascript" src="/scripts/jquery/jquery.json-2.2.js"></SCRIPT>
<script type="text/javascript" src="/scripts/common/dateFormat.js"></script>
<script type="text/javascript" src="/scripts/common/common.js?v=20180126"></script>
<script type="text/javascript" src="/scripts/common/jsMap.js"></script>
<script type="text/javascript" src="/scripts/common/constants.js?v=20180126"></script>

<script type="text/javascript" src="/scripts/jquery.easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/scripts/jquery.easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="/scripts/jquery.easyui/jquery.validatebox.js"></script>
<script  type="text/javascript">

//**********百度统计 start************
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?273679bd90479df18d4743569a779247";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
//**********百度统计 end************

function getContextPath(){
	return  ""; 
}

function getDeviceName(deviceId){
	var deviceCache = window.parent.device_cache;
	var name = deviceCache.get(deviceId);
	if(!name || name==null || name==""){
		var url=management_api_server_servlet_path+"/common/device/"+deviceId+".json";
		var data={}
		var result = ajaxSyncGet(url,data);
		if (result.code!=0) {
			showErrorMessage(result.message);
			return;
		}
		var data = result.data;
		if(data){
			deviceCache.put(data.id,data.name); 
		}else{
			deviceCache.put(deviceId,"终端已删除"); 
		}
		name = deviceCache.get(deviceId);
	}
	return name;
}

function isOnline(deviceId){
	var url=management_api_server_servlet_path+"/device/"+deviceId+"/state.json";
	var data={}
	var result=ajaxSyncGet(url,data);
	if(result&&result.data&&result.data.length >0){
		var item = result.data[0];
		return item.state==3;
	}
	return false;
}

</script><script type="text/javascript" src="/scripts/map/gaodeMap.js?v=201800320"></script>
<script type="text/javascript" src="/scripts/map/mapUtil.js?v=20180126"></script>
<script type="text/javascript" src="/dwr/engine.js"></script>
<script type="text/javascript" src="/dwr/util.js"></script>
<script type="text/javascript" src="/dwr/interface/DWRMessagePusher.js"></script>
<script type="text/javascript" src="/scripts/map/lngLatConverter.js"></script>
<script type="text/javascript" src="/scripts/imagesbox/jquery.poptrox.js"></script>
</head>
<body>
	<div id="map" style="width:99%"></div>
	
	
	
	
	<div id="district-search-tip">
    	省：<select id='district-search-province' style="width:100px" onchange="searchDistrict(this,'city')"></select>
    	市：<select id='district-search-city' style="width:100px" onchange="searchDistrict(this,'district')"></select>
    	区：<select id='district-search-district' style="width:100px" onchange="searchDistrict(this,'biz_area')"></select>
    	<a href="#" style="height:20px;top: 5px;" class="easyui-linkbutton" iconCls="icon-search" onclick="searchDeviceByDistrict()">查车</a>
	</div>
	
	<div class="easyui-tabs" style="width:99%;height:180px;" data-options="tools:'#tab-tools'">
		<div title="设备详情">
		<table id="device-info-datagrid" class="easyui-datagrid" style="width:100%;height:140px" data-options="rownumbers:true,singleSelect:true">
			<thead data-options="frozen:true">
				<tr>
				    <th data-options="field:'deviceId',hidden:true">id</th>
					<th data-options="field:'name',width:80">设备名称</th>
					<th data-options="field:'simCode',width:110,align:'center'">sim卡号</th>
				</tr>
			</thead>
			<thead>
				<tr>
					<th data-options="field:'state',width:50,align:'center'">状态</th>
					<th data-options="field:'gpsTime',width:150,align:'center'">更新时间</th>
					<th data-options="field:'speed',width:80,align:'center'">速度(km/h)</th>
					<th data-options="field:'mileage',width:80,align:'center'">里程(km)</th>
					<th data-options="field:'oilmass',width:80,align:'center'">油量(L)</th>
					<th data-options="field:'lng',width:100,align:'center'">经度</th>
					<th data-options="field:'lat',width:100,align:'center'">纬度</th>
					<th data-options="field:'altitude',width:60,align:'center'">海拔(m)</th>
					<th data-options="field:'statusFlag',width:1300">部件状态</th>
				</tr>
			</thead>
		</table>
		</div>
		<div title="告警">
			<table id="device-alarm-datagrid" class="easyui-datagrid" style="width:100%;height:140px" data-options="rownumbers:true,singleSelect:true">
			<thead data-options="frozen:true">
				<tr>
				    <th data-options="field:'deviceId',hidden:true">id</th>
					<th data-options="field:'deviceName',width:80">设备名称</th>
					<th data-options="field:'simCode',width:110,align:'center'">sim卡号</th>
				</tr>
			</thead>
			<thead>
				<tr>
					<th data-options="field:'alarmTime',width:150,align:'center'">告警时间</th>
					<th data-options="field:'alarmInfo',width:600">告警信息</th>
					<th data-options="field:'statusFlag',width:1300">部件状态</th>
				</tr>
			</thead>
		</table>
		</div>
		<div title="指令">
		<table id="device-cmd-datagrid" class="easyui-datagrid" style="width:100%;height:140px" data-options="rownumbers:true,singleSelect:true">
			<thead data-options="frozen:true">
				<tr>
				    <th data-options="field:'id',hidden:true">id</th>
					<th data-options="field:'deviceName',width:80">设备名称</th>
					<th data-options="field:'simCode',width:110,align:'center'">sim卡号</th>
				</tr>
			</thead>
			<thead>
				<tr>
					<th data-options="field:'state',width:120,align:'center'">状态</th>
					<th data-options="field:'messageDesc',width:250,align:'center'">指令</th>
					<th data-options="field:'messageId',width:150,align:'center'">消息id</th>
					<th data-options="field:'messageSeq',width:120">消息流水号</th>
					<th data-options="field:'createTime',width:160">下发时间</th>
				</tr>
			</thead>
		</table>
		</div>
	</div>
	<div id="tab-tools"style="border-style:solid none;">
		<a href="javascript:void(0)" onclick="resetTabs()" id="tab-tools-1" >折叠 </a>&nbsp;
	</div>
	<div id="move-alarm-setting-dlg" class="easyui-dialog" title="原地设防" style="width: 400px; height: 320px; padding: 10px 20px" closed="true" buttons="#move-alarm-setting-dlg-buttons">
	<form id="move-alarm-setting-dlg-frm" method="post">
		<input name="type" type="hidden" value="1">
		<input name="deviceId" id="move-alarm-setting-dlg-frm-deviceId" type="hidden">
		<div class="fitem">
			<label>设备名称：</label><input name="deviceName" id="move-alarm-setting-dlg-frm-name" maxlength="16"  class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>规则名称：</label><input name="name" maxlength="16"  required="true" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>持续时间：</label><select name="duration" class="easyui-validatebox textbox" required="true" missingMessage="告警多久后结束">
					  <option  value ="10">10分钟</option>
					  <option  value ="15">15分钟</option>
					  <option  value ="30">30分钟</option>
			</select>
		</div>
		<div class="fitem">
			<label>告警间隔：</label><select name="interval" class="easyui-validatebox textbox" required="true" missingMessage="告警多久后结束">
					  <option  value ="30">30秒</option>
					  <option  value ="60">60秒</option>
					  <option  value ="120">120秒</option>
			</select>
		</div>
		<div class="fitem">
			<label>开始时间：</label><input class="easyui-datetimebox" name="startTime" id="move-alarm-setting-dlg-frm-startTime" editable="false" data-options="required:true,showSeconds:false" missingMessage="设置有效开始时间">
		</div>
		<div class="fitem">
			<label>结束时间：</label><input class="easyui-datetimebox" name="endTime" id="move-alarm-setting-dlg-frm-endTime" editable="false" data-options="required:true,showSeconds:false"  missingMessage="设置有效结束时间">
		</div>
	</form>
</div>
<div id="move-alarm-setting-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveMoveAlarmSetting()">保存</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeDialog('move-alarm-setting-dlg')">关闭</a>
</div>

<div id="rail-alarm-setting-menu" class="easyui-menu" style="width:100px;">
		<div onclick="drawRail(1)">圆形围栏</div>
		<div onclick="drawRail(2)">矩形围栏</div>
		<div onclick="drawRail(3)">多边形围栏</div>
		<div onclick="districtRail()">区域围栏</div>
</div>

<div id="rail-alarm-setting-dlg" class="easyui-dialog" title="围栏告警设置" style="width: 430px; height: 380px; padding: 10px 20px" closed="true" buttons="#rail-alarm-setting-dlg-buttons">
	<form id="rail-alarm-setting-dlg-frm" method="post">
		<input name="type" type="hidden" value="2">
		<input name="shape" id="rail-alarm-setting-dlg-frm-shape" type="hidden">
		<input name="path" id="rail-alarm-setting-dlg-frm-path"  type="hidden">
		<input name="radius" id="rail-alarm-setting-dlg-frm-radius" type="hidden">
		<input name="lat" id="rail-alarm-setting-dlg-frm-lat" type="hidden">
		<input name="lng" id="rail-alarm-setting-dlg-frm-lng" type="hidden">
		<input name="deviceId" id="rail-alarm-setting-dlg-frm-deviceId" type="hidden">
		<div class="fitem">
			<label>设备名称：</label><input name="deviceName" id="rail-alarm-setting-dlg-frm-name" maxlength="16"  class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>规则名称：</label><input name="name" maxlength="16" required="true" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>围栏类型：</label><select name="inside" id="rail-alarm-setting-dlg-frm-inside" class="easyui-validatebox textbox" required="true">
					  <option  value ="0">出围栏告警</option>
					  <option  value ="1">进围栏告警</option>
					  <option  value ="2">围栏超速告警</option>
			</select>
		</div>
		<div class="fitem" id="rail-alarm-setting-dlg-frm-speed-div" style="display:none">
			<label>围栏限速：</label><input name="speed"  maxlength="3"  class="easyui-validatebox textbox" missingMessage="围栏内超过此速度告警" validType="integer">
		</div>
		<div class="fitem">
			<label>有效星期：</label><input type="checkbox" class="textbox" style="width:15px;" name="week" value="1" >
			<label style="width:15px;">一</label>
			<input type="checkbox" class="textbox" style="width:15px;" name="week" value="2" >
			<label style="width:15px;">二</label>
			<input type="checkbox" class="textbox" style="width:15px;" name="week" value="3" >
			<label style="width:15px;">三</label>
			<input type="checkbox" class="textbox" style="width:15px;" name="week" value="4" >
			<label style="width:15px;">四</label>
			<input type="checkbox" class="textbox" style="width:15px;" name="week" value="5" >
			<label style="width:15px;">五</label>
			<input type="checkbox" class="textbox" style="width:15px;" name="week" value="6" >
			<label style="width:15px;">六</label>
			<input type="checkbox" class="textbox" style="width:15px;" name="week" value="0" >
			<label style="width:15px;">日</label>
		</div>
		<div class="fitem">
			<label>有效时段：</label><select name="startHour" id="rail-alarm-setting-dlg-frm-startHour" class="easyui-validatebox textbox" style="width:80px;">
			</select>
			<label style="width:30px;">&nbsp;&nbsp;至</label>
			<select name="endHour" id="rail-alarm-setting-dlg-frm-endHour"  class="easyui-validatebox textbox" style="width:80px;">
			</select>
		</div>
		<div class="fitem">
			<label>开始时间：</label><input class="easyui-datetimebox" name="startTime" id="rail-alarm-setting-dlg-frm-startTime" editable="false" data-options="required:true,showSeconds:false" missingMessage="设置有效开始时间">
		</div>
		<div class="fitem">
			<label>结束时间：</label><input class="easyui-datetimebox" name="endTime" id="rail-alarm-setting-dlg-frm-endTime" editable="false" data-options="required:true,showSeconds:false"  missingMessage="设置有效结束时间">
		</div>
	</form>
</div>
<div id="rail-alarm-setting-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveRailAlarmSetting()">保存</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeDialog('rail-alarm-setting-dlg')">关闭</a>
</div>


<div id="district-alarm-setting-dlg" class="easyui-dialog" title="围栏告警设置" style="width:500px; height:500px; padding: 10px 20px" closed="true" buttons="#district-alarm-setting-dlg-buttons">
	<form id="district-alarm-setting-dlg-frm" method="post">
		<input name="type" type="hidden" value="2">
		<input name="shape" id="district-alarm-setting-dlg-frm-shape" type="hidden" value="4">
		<input name="deviceId" id="district-alarm-setting-dlg-frm-deviceId" type="hidden">
		<div class="fitem">
			<label>设备名称：</label><input name="deviceName" id="district-alarm-setting-dlg-frm-name" maxlength="16"  class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>规则名称：</label><input name="name" maxlength="16" required="true" class="easyui-validatebox textbox">
		</div>
		
		<div class="fitem">
			<label>省份：</label><select id="district-alarm-setting-dlg-frm-province"  class="textbox"  onchange='searchAlarmDistrict(this)'></select>
		</div>
		
		<div class="fitem">
			<label>市区：</label><select id="district-alarm-setting-dlg-frm-city" class="textbox" onchange='searchAlarmDistrict(this)'></select>
		</div>
		
		<div class="fitem">
			<label>区域：</label><select id="district-alarm-setting-dlg-frm-district"  class="textbox" onchange='searchAlarmDistrict(this)'></select>
		</div>
		
		<div class="fitem">
			<label>围栏类型：</label><select name="inside" id="district-alarm-setting-dlg-frm-inside" class="easyui-validatebox textbox" required="true">
					  <option  value ="0">出围栏告警</option>
					  <option  value ="1">进围栏告警</option>
					  <option  value ="2">围栏超速告警</option>
			</select>
		</div>
		<div class="fitem" id="district-alarm-setting-dlg-frm-speed-div" style="display:none">
			<label>围栏限速：</label><input name="speed"  maxlength="3"  class="easyui-validatebox textbox" missingMessage="围栏内超过此速度告警" validType="integer">
		</div>
		<div class="fitem">
			<label>有效星期：</label><input type="checkbox" class="textbox" style="width:15px;" name="week" value="1" >
			<label style="width:15px;">一</label>
			<input type="checkbox" class="textbox" style="width:15px;" name="week" value="2" >
			<label style="width:15px;">二</label>
			<input type="checkbox" class="textbox" style="width:15px;" name="week" value="3" >
			<label style="width:15px;">三</label>
			<input type="checkbox" class="textbox" style="width:15px;" name="week" value="4" >
			<label style="width:15px;">四</label>
			<input type="checkbox" class="textbox" style="width:15px;" name="week" value="5" >
			<label style="width:15px;">五</label>
			<input type="checkbox" class="textbox" style="width:15px;" name="week" value="6" >
			<label style="width:15px;">六</label>
			<input type="checkbox" class="textbox" style="width:15px;" name="week" value="0" >
			<label style="width:15px;">日</label>
		</div>
		<div class="fitem">
			<label>有效时段：</label><select name="startHour" id="district-alarm-setting-dlg-frm-startHour" class="easyui-validatebox textbox" style="width:80px;">
			</select>
			<label style="width:30px;">&nbsp;&nbsp;至</label>
			<select name="endHour" id="district-alarm-setting-dlg-frm-endHour"  class="easyui-validatebox textbox" style="width:80px;">
			</select>
		</div>
		<div class="fitem">
			<label>开始时间：</label><input class="easyui-datetimebox" name="startTime" id="district-alarm-setting-dlg-frm-startTime" editable="false" data-options="required:true,showSeconds:false" missingMessage="设置有效开始时间">
		</div>
		<div class="fitem">
			<label>结束时间：</label><input class="easyui-datetimebox" name="endTime" id="district-alarm-setting-dlg-frm-endTime" editable="false" data-options="required:true,showSeconds:false"  missingMessage="设置有效结束时间">
		</div>
	</form>
</div>
<div id="district-alarm-setting-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveDistrictAlarmSetting()">保存</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeDialog('district-alarm-setting-dlg')">关闭</a>
</div>


<div id="overspeed-alarm-setting-dlg" class="easyui-dialog" title="超速告警设置" style="width: 400px; height: 350px; padding: 10px 20px" closed="true" buttons="#overspeed-alarm-setting-dlg-buttons">
	<form id="overspeed-alarm-setting-dlg-frm" method="post">
		<input name="type" type="hidden" value="3">
		<input name="deviceId" id="overspeed-alarm-setting-dlg-frm-deviceId" type="hidden">
		<div class="fitem">
			<label>设备名称：</label><input name="deviceName" id="overspeed-alarm-setting-dlg-frm-name" maxlength="16"  class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>规则名称：</label><input name="name" maxlength="16"  required="true" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>限速：</label><input name="speed"  maxlength="3"  class="easyui-validatebox textbox" required="true" missingMessage="超过此速度告警" validType="integer">
		</div>
		<div class="fitem">
			<label>有效时段：</label><select name="startHour" id="overspeed-alarm-setting-dlg-frm-startHour" class="easyui-validatebox textbox" style="width:80px;">
			</select>
			<label style="width:30px;">&nbsp;&nbsp;至</label>
			<select name="endHour" id="overspeed-alarm-setting-dlg-frm-endHour"  class="easyui-validatebox textbox" style="width:80px;">
			</select>
		</div>
		<div class="fitem">
			<label>告警间隔：</label><select name="interval" class="easyui-validatebox textbox" required="true" missingMessage="告警多久后结束">
					  <option  value ="30">30秒</option>
					  <option  value ="60">60秒</option>
					  <option  value ="120">120秒</option>
			</select>
		</div>
		<div class="fitem">
			<label>开始时间：</label><input class="easyui-datetimebox" name="startTime" id="overspeed-alarm-setting-dlg-frm-startTime" editable="false" data-options="required:true,showSeconds:false" missingMessage="设置有效开始时间">
		</div>
		<div class="fitem">
			<label>结束时间：</label><input class="easyui-datetimebox" name="endTime" id="overspeed-alarm-setting-dlg-frm-endTime" editable="false" data-options="required:true,showSeconds:false"  missingMessage="设置有效结束时间">
		</div>
	</form>
</div>
<div id="overspeed-alarm-setting-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveOverspeedAlarmSetting()">保存</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeDialog('overspeed-alarm-setting-dlg')">关闭</a>
</div>

<script  type="text/javascript">
$(document).ready(function() {
	setHourOption("overspeed-alarm-setting-dlg-frm-startHour",true);
	setHourOption("overspeed-alarm-setting-dlg-frm-endHour",false);
	setHourOption("rail-alarm-setting-dlg-frm-startHour",true);
	setHourOption("rail-alarm-setting-dlg-frm-endHour",false);
	setHourOption("district-alarm-setting-dlg-frm-startHour",true);
	setHourOption("district-alarm-setting-dlg-frm-endHour",false);

	$(document).on("change",'select#rail-alarm-setting-dlg-frm-inside',function(){
	     if($(this).val()=="2"){
	    	 $("#rail-alarm-setting-dlg-frm-speed-div").show();
	     }else{
	    	 $("#rail-alarm-setting-dlg-frm-speed-div").hide();
	     }
	});
	
	$(document).on("change",'select#district-alarm-setting-dlg-frm-inside',function(){
	     if($(this).val()=="2"){
	    	 $("#district-alarm-setting-dlg-frm-speed-div").show();
	     }else{
	    	 $("#district-alarm-setting-dlg-frm-speed-div").hide();
	     }
	});
});

function showRailAlarmSettingMenu(x,y){
	$("#rail-alarm-setting-menu").menu("show", {
		left: x,
		top: y
	});
}

var current_circle = null;
var current_polygon = null;
function setRailAlarm(dialogId){
	current_dialog_id=dialogId;
	openDialog(dialogId)
}

var railLabelMap= new JsMap();
var railLabelTextMap;
var weekMap= new JsMap();
weekMap.put("0","日");
weekMap.put("1","一");
weekMap.put("2","二");
weekMap.put("3","三");
weekMap.put("4","四");
weekMap.put("5","五");
weekMap.put("6","六");

function loadRail(){
	if(!current_selected_device){
		showMessage("请选择要操作的设备！");
		return;
	}
	var url=management_api_server_servlet_path+"/common/query/deviceAlarmSetting.json?select=name,setting";
	var now = new Date().format();
	var data={};
	data["state.eq"]=1;
	data["type.eq"]=2;
	data["deviceId.eq"]=current_selected_device.id;
	data["startTime.lte"]=now;
	data["endTime.gte"]=now;
	ajaxAsyncPost(url,data,function(result){
		if(!result || !result.data ||result.data.length <=0){
			showMessage("所查询的设备无有效围栏数据！");
			return;
		}

		result=result.data;
		railLabelTextMap= new JsMap();
		for(var i=0;i<result.length;i++){
			//{"radius":"5492","inside":"0","lat":30.120334,"lng":109.203745,"startHour":"0","endHour":"0","week":["1","2"]}
			var arr = result[i];
			var item=JSON.parse(arr[1]);
			var startHour=item.startHour<10?"0"+item.startHour+":00":item.startHour+":00";
			var endHour=item.endHour<10?"0"+item.endHour+":59":item.endHour+":59";
			var type=item.inside==0?"出围栏告警":"进围栏告警";
			var weeks=item.week;
			var weekstr="";
			if(weeks&&weeks.length>0){
				for(var j=0;j<weeks.length;j++){
					weekstr+=","+weekMap.get(weeks[j]);
				}
				weekstr=weekstr.substr(1)
			}
			var text="";
			if(arr[0]){
				text="围栏名称："+arr[0]+"<br>";
			}
			text +="围栏类型："+type+"<br>有效星期："+weekstr+"<br>有效时段："+startHour+"-"+endHour;
			
			if(item.shape==1){
				var gcj02 = LngLatConverter.wgs84togcj02(item.lng,item.lat);
				var point=mapUtil.getPoint(gcj02[0],gcj02[1]);
				var circle=mapUtil.addCircle(point,item.radius);
				railLabelTextMap.put(circle,text);
				circle.on("mouseover",function(e){
					circle = e.target;
					var text =railLabelTextMap.get(circle);
					railLabelMap.put(circle,mapUtil.addLabel(circle.getCenter(),text));
				});
				circle.on("mouseout",function(e){
					circle = e.target;
					mapUtil.removeOverlay(railLabelMap.get(circle));
					railLabelMap.remove(circle);
				});
			}else if(item.shape==4){
				var bounds = item.bounds;
				for(var j=0;j<bounds.length;j++){
					var arr = bounds[j].split(";");
					var path = new Array();
					for(var k=0,l=arr.length;k<l;k++){
						var point = arr[k].split(",");
						var gcj02 = LngLatConverter.wgs84togcj02(point[0],point[1]);
						path.push(mapUtil.getPoint(gcj02[0],gcj02[1]));
					}
					mapUtil.addPolygon(path);
				}
			}else{
				var arr = item.path.split(";");
				var path = new Array();
				for(var j=0;j<arr.length;j++){
					var point = arr[j].split(",");
					var gcj02 = LngLatConverter.wgs84togcj02(point[0],point[1]);
					path.push(mapUtil.getPoint(gcj02[0],gcj02[1]));
				}
				var polygon=mapUtil.addPolygon(path);
				railLabelTextMap.put(polygon,text);
				polygon.on("mouseover",function(e){
					polygon = e.target;
					var text =railLabelTextMap.get(polygon);
					railLabelMap.put(polygon,mapUtil.addLabel(polygon.getBounds().getCenter(),text));
				});
				polygon.on("mouseout",function(e){
					polygon = e.target;
					mapUtil.removeOverlay(railLabelMap.get(polygon));
					railLabelMap.remove(polygon);
				});
			}
		}
		mapUtil.getMap().setFitView();
	});
}

function drawRail(type){
	if(!current_selected_device){
		showMessage("请选择要操作的设备！");
		return;
	}
	mapUtil.closeDraw();
	mapUtil.openDraw();
	var message = "";
	if(type==1){
		message = "画圆形";
		mapUtil.drawCircle(drawCircleCompletedHandler);
	}else if(type==2){
		message = "画矩形";
		mapUtil.drawRectangle(drawPolygonCompletedHandler);
	}else if(type==3){
		message = "画多边形";
		mapUtil.drawPolygon(drawPolygonCompletedHandler);
	}
	current_dialog_id="rail-alarm-setting-dlg";
	$("#"+current_dialog_id+"-frm-shape").val(type);
	showMessage("请在地图上画"+message+"电子围栏！");
}

function districtRail(){
	if(!current_selected_device){
		showMessage("请选择要操作的设备！");
		return;
	}
	current_dialog_id="district-alarm-setting-dlg";
	openDialog(current_dialog_id);
}

function searchAlarmDistrict(object){
	 //清除地图上所有覆盖物
   for (var i = 0, l = current_district_polygons.length; i < l; i++) {
   	current_district_polygons[i].setMap(null);
   }
   var arr = $(object).val().split(",");
   var district = mapUtil.getDistrictSearch();
   district.setLevel(arr[1]); //行政区级别
   district.setExtensions("all");
   district.setSubdistrict(1);
   //行政区查询
   //按照adcode进行查询可以保证数据返回的唯一性
   district.search(arr[0], function(status, result) {
       if(status === 'complete'){
    	   setDistrictRailSearchResult(result);
       }
   });
}

var district_alarm_setting_dlg_frm_bounds;
var district_alarm_setting_dlg_frm_level;
var district_alarm_setting_dlg_frm_areaCode;
function setDistrictRailSearchResult(result) {
	current_district_polygons=[];
	var district = result.districtList[0];
    var boundaries = district.boundaries;
    var map = mapUtil.getMap();
    if (boundaries) {
    	var bounds=[];
        for (var i = 0, l = boundaries.length; i < l; i++) {
        	var points = boundaries[i];
	   		var path="";
	   		for(var j = 0; j< points.length;j++){
	   			var point = points[j];
	   			var wgs84 = LngLatConverter.gcj02towgs84(point.getLng(), point.getLat());
	   			path+=";"+wgs84[0]+","+wgs84[1];
	   		}
	   		if(path!=""){
	   			 bounds.push(path.substr(1));
	   		}
        	var polygon=mapUtil.addPolygon(points);
            current_district_polygons.push(polygon);
        }
        map.setFitView();//地图自适应
        district_alarm_setting_dlg_frm_bounds=bounds;
    }
    district_alarm_setting_dlg_frm_areaCode = district.adcode;
    district_alarm_setting_dlg_frm_level = district.level;
    var subList = district.districtList;
    if (subList) {
    	 var level = district.level;
    	 var select = $("#district-alarm-setting-dlg-frm-province");
         //清空下一级别的下拉列表
         if(level === 'country'){
        	 
         }else if (level === 'province') {
        	 $("#district-alarm-setting-dlg-frm-city").empty();
        	 $("#district-alarm-setting-dlg-frm-district").empty();
        	 select = $("#district-alarm-setting-dlg-frm-city");
         } else if (level === 'city') {
        	 $("#district-alarm-setting-dlg-frm-district").empty();
        	 select = $("#district-alarm-setting-dlg-frm-district");
         }else if(level === 'district'){
        	 return;
         }
         select.append("<option value=''>--请选择--</option>");
         for (var i = 0, l = subList.length; i < l; i++) {
        	 var item = subList[i];
        	 select.append("<option value='"+item.adcode+","+item.level+"'>"+item.name+"</option>");
         }
     }
}

function drawCircleCompletedHandler(e, circle){
	circle=e.obj;
	current_circle=circle;
	var point=circle.getCenter();
	
	//国测局坐标转wgs84坐标
    var wgs84 = LngLatConverter.gcj02towgs84(point.getLng(), point.getLat());
	$("#"+current_dialog_id+"-frm-radius").val(parseInt(circle.getRadius()));
	$("#"+current_dialog_id+"-frm-lat").val(wgs84[1]);
	$("#"+current_dialog_id+"-frm-lng").val(wgs84[0]);
	mapUtil.closeDraw();
	openDialog(current_dialog_id);
}

function drawPolygonCompletedHandler(e, polygon){
	polygon=e.obj;
	current_polygon=polygon;
	var path=polygon.getPath();
	var points = "";
	//国测局坐标转wgs84坐标
	for(var i=0;i<path.length;i++){
		var point = path[i];
		var wgs84 = LngLatConverter.gcj02towgs84(point.getLng(), point.getLat());
		points+=";"+wgs84[0]+","+wgs84[1];
	}
    
	$("#"+current_dialog_id+"-frm-path").val(points.substr(1));
	mapUtil.closeDraw();
	openDialog(current_dialog_id);
}

function setHourOption(id,start){
	for(var i=0;i<24;i++){
		var text=i;
		if(i<10){
			text="0"+i;
		}
		if(start){
			text+=":00";
		}else{
			text+=":59";
		}
		
		$("#"+id).append("<option value='"+i+"'>"+text+"</option>");
	}
}

function saveMoveAlarmSetting(){
	if(current_selected_device_lacation==null){
		showMessage(current_selected_device.name+"未定位，设置失败！");
		return;
	}
	if(!$("#move-alarm-setting-dlg-frm").form('validate')) return;
	var data = $("#move-alarm-setting-dlg-frm").serializeObject();
	
	var setting={};
	setting.duration=data.duration;
	setting.interval=data.interval;
	setting.radius=150;
    var wgs84 = LngLatConverter.gcj02towgs84(current_selected_device_lacation.lng,current_selected_device_lacation.lat);
	setting.lat=wgs84[1];
	setting.lng=wgs84[0];
	data.setting=JSON.stringify(setting);
	var url=management_api_server_servlet_path+"/common/deviceAlarmSetting.json";
	ajaxAsyncPost(url,data,function(result){
		if (result.code!=0) {
			showErrorMessage(result.message);
		}  else {
			closeDialog("move-alarm-setting-dlg");
			showMessage("设置成功");
		}
	});
}

function saveRailAlarmSetting(){
	if(current_selected_device_lacation==null){
		showMessage(current_selected_device.name+"未定位，设置失败！");
		return;
	}
	if(!$("#rail-alarm-setting-dlg-frm").form('validate')) return;
	var data = $("#rail-alarm-setting-dlg-frm").serializeObject();
	
	var week = new Array();
	var index=0;
	$("input[name='week']").each(function(){
        if ($(this).attr('checked')) {
        	week[index++]=$(this).val();
          }
   });
	var setting={};
	setting.shape = data.shape;
	setting.inside=data.inside;
	if(data.shape==1){
		setting.radius=data.radius;
		setting.lat=data.lat;
		setting.lng=data.lng;
	}else{
		setting.path=data.path;
	}
	setting.startHour=data.startHour;
	setting.endHour=data.endHour;
	if(data.startHour > data.endHour){
		showMessage("结束时段必须大于开始开始时段！");
		return;
	}
	if(week.length>0){
		setting.week=week;
	}else{
		showMessage("请正确设置有效星期");
		return;
	}
	if(data.inside=="2"){
		if(data.speed==""){
			showMessage("请设置限速值");
			return;
		}else{
			setting.speed=data.speed;
		}
	}
	data.setting=JSON.stringify(setting);
	var url=management_api_server_servlet_path+"/common/deviceAlarmSetting.json";
	ajaxAsyncPost(url,data,function(result){
		if (result.code!=0) {
			showErrorMessage(result.message);
		}  else {
			if(current_circle){
				mapUtil.removeOverlay(current_circle);
			}
			if(current_polygon){
				mapUtil.removeOverlay(current_polygon);
			}
			closeDialog("rail-alarm-setting-dlg");
			showMessage("设置成功");
		}
	});
}

function saveOverspeedAlarmSetting(){
	if(current_selected_device_lacation==null){
		showMessage(current_selected_device.name+"未定位，设置失败！");
		return;
	}
	if(!$("#overspeed-alarm-setting-dlg-frm").form('validate')) return;
	var data = $("#overspeed-alarm-setting-dlg-frm").serializeObject();
	
	if(data.speed=="" || data.speed <=0){
		showMessage("请正确设置限速值");
		return;
	}
	var setting={};
	setting.speed=data.speed;
	setting.interval=data.interval;
	setting.startHour=data.startHour;
	setting.endHour=data.endHour;
	
	if(data.startHour > data.endHour){
		showMessage("结束时段必须大于开始开始时段！");
		return;
	}
	data.setting=JSON.stringify(setting);
	var url=management_api_server_servlet_path+"/common/deviceAlarmSetting.json";
	ajaxAsyncPost(url,data,function(result){
		if (result.code!=0) {
			showErrorMessage(result.message);
		}  else {
			closeDialog("overspeed-alarm-setting-dlg");
			showMessage("设置成功");
		}
	});
}

function saveDistrictAlarmSetting(){
	if(current_selected_device_lacation==null){
		showMessage(current_selected_device.name+"未定位，设置失败！");
		return;
	}
	if(!$("#district-alarm-setting-dlg-frm").form('validate')) return;
	var data = $("#district-alarm-setting-dlg-frm").serializeObject();
	
	var week = new Array();
	var index=0;
	$("input[name='week']").each(function(){
        if ($(this).attr('checked')) {
        	week[index++]=$(this).val();
          }
   });
	var setting={};
	setting.shape = data.shape;
	setting.inside=data.inside;
	if(!district_alarm_setting_dlg_frm_bounds){
		showMessage("请行政区域");
		return;
	}

	var tolerance=500;
	if(district_alarm_setting_dlg_frm_level=="province"){
		tolerance=2000;
	}else if(district_alarm_setting_dlg_frm_level=="city"){
		tolerance=1000;
	}

	var url=lbs_api_server_servlet_path+"/gps/district/simple.json";
	//抽稀算法，省2000米，市1000米，区500米
	var result = ajaxSyncPost(url,{"bounds":district_alarm_setting_dlg_frm_bounds,"tolerance":tolerance});
	if (result.code!=0) {
		showErrorMessage(result.message);
		return;
	}
	setting.bounds=result.data;
	setting.startHour=data.startHour;
	setting.endHour=data.endHour;
	
	if(data.startHour > data.endHour){
		showMessage("结束时段必须大于开始开始时段！");
		return;
	}
	if(week.length>0){
		setting.week=week;
	}else{
		showMessage("请正确设置有效星期");
		return;
	}
	if(data.inside=="2"){
		if(data.speed==""){
			showMessage("请设置限速值");
			return;
		}else{
			setting.speed=data.speed;
		}
	}
	
	var url=management_api_server_servlet_path+"/common/query/dictionary/districtSearchData.json?select=centerLng,centerLat,maxRadius";
	var result = ajaxSyncPost(url,{"code.eq":district_alarm_setting_dlg_frm_areaCode});
	if (result.code!=0) {
		showErrorMessage(result.message);
		return;
	}
	if(result.data && result.data.length > 0){
		var item = result.data[0];
		var center = {};
		center.lng = item[0];
		center.lat = item[1];
		center.radius = item[2];
		setting.center = center;
	}

	data.setting=JSON.stringify(setting);
	var url=management_api_server_servlet_path+"/common/deviceAlarmSetting.json";
	ajaxAsyncPost(url,data,function(result){
		if (result.code!=0) {
			showErrorMessage(result.message);
		}  else {
			for (var i = 0, l = current_district_polygons.length; i < l; i++) {
			   	current_district_polygons[i].setMap(null);
			}
			district_alarm_setting_dlg_frm_bounds=null;
			closeDialog("district-alarm-setting-dlg");
			showMessage("设置成功");
		}
	});
}
</script><div id="send-take-picture-cmd-dlg"  class="easyui-dialog" title="拍照指令" style="width: 400px; height: 170px; padding: 10px 20px" closed="true" buttons="#send-take-picture-cmd-dlg-buttons">
	<form id="send-take-picture-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-take-picture-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8801">
		<input name="commandType" type="hidden" value="2">
		<input name="totalPicture" type="hidden" value="1">
		<input name="executionTime" type="hidden" value="0">
		<input name="saveFlag" type="hidden" value="0">
		<input name="resolution" type="hidden" value="2">
		<input name="quality" type="hidden" value="1">
		<input name="luminance" type="hidden" value="127">
		<input name="contrast" type="hidden" value="1">
		<input name="saturation" type="hidden" value="1">
		<input name="chromaticity" type="hidden" value="1">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-take-picture-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>拍摄通道：</label><select name="channelId" class="easyui-validatebox textbox" required="true" missingMessage="调用哪个摄像头拍摄">
					  <option  value ="1">1</option>
					  <option  value ="2">2</option>
					  <option  value ="3">3</option>
					  <option  value ="4">4</option>
					  <option  value ="5">5</option>
					  <option  value ="6">6</option>
					  <option  value ="7">7</option>
					  <option  value ="8">8</option>
			</select>
		</div>
	</form>
</div>
<div id="send-take-picture-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>


<div id="send-phone-tapping-cmd-dlg"  class="easyui-dialog" title="监听指令" style="width: 400px; height: 170px; padding: 10px 20px" closed="true" buttons="#send-phone-tapping-cmd-dlg-buttons">
	<form id="send-phone-tapping-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-phone-tapping-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8400">
		<input name="type" type="hidden" value="1">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-phone-tapping-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>回拨电话：</label><input name="tel" maxlength="16"  class="easyui-validatebox textbox" required="true" missingMessage="接听的手机号或者电话号码" validType="phoneOrMobile">
		</div>
	</form>
</div>
<div id="send-phone-tapping-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>

<div id="send-phone-call-cmd-dlg"  class="easyui-dialog" title="远程通话指令" style="width: 400px; height: 170px; padding: 10px 20px" closed="true" buttons="#send-phone-call-cmd-dlg-buttons">
	<form id="send-phone-call-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-phone-call-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8400">
		<input name="type" type="hidden" value="0">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-phone-call-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>回拨电话：</label><input name="tel" maxlength="16"  class="easyui-validatebox textbox" required="true" missingMessage="接听的手机号或者电话号码" validType="phoneOrMobile">
		</div>
	</form>
</div>
<div id="send-phone-call-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>


<div id="send-car-lock-cmd-dlg"  class="easyui-dialog" title="车门加锁指令" style="width: 400px; height: 135px; padding: 10px 20px" closed="true" buttons="#send-car-lock-cmd-dlg-buttons">
	<form id="send-car-lock-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-car-lock-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8500">
		<input name="flag" type="hidden" value="10000000">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-car-lock-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
	</form>
</div>
<div id="send-car-lock-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>


<div id="send-car-unlock-cmd-dlg"  class="easyui-dialog" title="车门解锁指令" style="width: 400px; height: 135px; padding: 10px 20px" closed="true" buttons="#send-car-unlock-cmd-dlg-buttons">
	<form id="send-car-unlock-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-car-unlock-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8500">
		<input name="flag" type="hidden" value="00000000">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-car-unlock-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
	</form>
</div>
<div id="send-car-unlock-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>


<div id="send-text-info-cmd-dlg"  class="easyui-dialog" title="文本信息指令" style="width:580px; height: 350px; padding: 10px 20px" closed="true" buttons="#send-text-info-cmd-dlg-buttons">
	<form id="send-text-info-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-text-info-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8300">
		<input name="flag" type="hidden" value="00010000">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-text-info-cmd-dlg-frm-name" style="width:380px;" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>文本信息：</label><textarea  name="text"  style="height:200px;width:380px;" class="easyui-validatebox textbox" required="true"/></textarea>
		</div>
	</form>
</div>
<div id="send-text-info-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>


<div id="send-car-location-query-cmd-dlg"  class="easyui-dialog" title="位置信息查询" style="width: 400px; height: 135px; padding: 10px 20px" closed="true" buttons="#send-car-location-query-cmd-dlg-buttons">
	<form id="send-car-location-query-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-car-location-query-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8201">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-car-location-query-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
	</form>
</div>
<div id="send-car-location-query-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>

<div id="send-stop-record-cmd-dlg"  class="easyui-dialog" title="停止录音" style="width: 400px; height: 135px; padding: 10px 20px" closed="true" buttons="#send-stop-record-cmd-dlg-buttons">
	<form id="send-stop-record-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-stop-record-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8804">
		<input name="commandType" type="hidden" value="0">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-stop-record-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
	</form>
</div>
<div id="send-stop-record-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>


<div id="send-start-record-cmd-dlg"  class="easyui-dialog" title="录音" style="width: 400px; height: 230px; padding: 10px 20px" closed="true" buttons="#send-start-record-cmd-dlg-buttons">
	<form id="send-start-record-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-start-record-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8804">
		<input name="commandType" type="hidden" value="1">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-start-record-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>录音时间：</label><input name="executionTime" required="true" maxlength="5" class="easyui-validatebox textbox">(秒)
		</div>
		<div class="fitem">
			<label>保存标识：</label><select name="saveFlag" class="easyui-validatebox textbox" required="true">
					  <option  value ="0">实时上传</option>
					  <option  value ="1">终端保存</option>
			</select>
		</div>
		<div class="fitem">
			<label>采样频率：</label><select name="samplingRate" class="easyui-validatebox textbox" required="true">
					<option value="0">8K</option>
         			<option value="1">11K</option>
         			<option value="2">23K</option>
         			<option value="3">32K</option>
			</select>
		</div>
	</form>
</div>
<div id="send-start-record-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>


<div id="send-take-one-picture-cmd-dlg"  class="easyui-dialog" title="单张拍照" style="width: 480px; height: 420px; padding: 10px 20px" closed="true" buttons="#send-take-one-picture-cmd-dlg-buttons">
	<form id="send-take-one-picture-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-take-one-picture-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8801">
		<input name="commandType" type="hidden" value="2">
		<input name="totalPicture" type="hidden" value="1">
		<input name="executionTime" type="hidden" value="0">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-take-one-picture-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>拍摄通道：</label><select name="channelId" class="easyui-validatebox textbox" required="true" missingMessage="调用哪个摄像头拍摄">
					  <option  value ="1">1</option>
					  <option  value ="2">2</option>
					  <option  value ="3">3</option>
					  <option  value ="4">4</option>
					  <option  value ="5">5</option>
					  <option  value ="6">6</option>
					  <option  value ="7">7</option>
					  <option  value ="8">8</option>
			</select>
		</div>
		<div class="fitem">
			<label>保存标识：</label><select name="saveFlag" class="easyui-validatebox textbox" required="true">
					  <option  value ="0">实时上传</option>
					  <option  value ="1">终端保存</option>
			</select>
		</div>
		<div class="fitem">
			<label>分辨率：</label><select name="resolution" class="easyui-validatebox textbox" required="true">
					 <option value="1">320*240</option>
					 <option value="2">640*480</option>
					 <option value="3">800*600</option>
					 <option value="4">1024*768</option>
					 <option value="5">176*144</option>
					 <option value="6">352*288</option>
					 <option value="7">704*288</option>
					 <option value="8">704*576</option>
			</select>
		</div>
		<div class="fitem">
			<label>图片质量：</label><select name="quality" class="easyui-validatebox textbox" required="true">
					 <option value="1">1</option>
					 <option value="2">2</option>
					 <option value="3">3</option>
					 <option value="4">4</option>
					 <option value="5">5</option>
					 <option value="6">6</option>
					 <option value="7">7</option>
					 <option value="8">8</option>
					 <option value="9">9</option>
					 <option value="10">10</option>
			</select>(值越小越高)
		</div>
		<div class="fitem">
			<label>亮度：</label><input name="luminance" value="127" maxlength="3" class="easyui-validatebox textbox">(0~255)
		</div>
		<div class="fitem">
			<label>对比度：</label><input name="contrast"  value="10" maxlength="3" class="easyui-validatebox textbox">(0~127)
		</div>
		<div class="fitem">
			<label>饱和度：</label><input name="saturation" value="10" maxlength="3" class="easyui-validatebox textbox">(0~127)
		</div>
		<div class="fitem">
			<label>色度：</label><input name="chromaticity"  value="127" maxlength="3" class="easyui-validatebox textbox">(0~255)
		</div>
	</form>
</div>
<div id="send-take-one-picture-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>


<div id="send-take-many-picture-cmd-dlg"  class="easyui-dialog" title="定时拍照" style="width: 480px; height: 505px; padding: 10px 20px" closed="true" buttons="#send-take-many-picture-cmd-dlg-buttons">
	<form id="send-take-many-picture-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-take-many-picture-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8801">
		<input name="commandType" type="hidden" value="2">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-take-many-picture-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>拍摄通道：</label><select name="channelId" class="easyui-validatebox textbox" required="true" missingMessage="调用哪个摄像头拍摄">
					  <option  value ="1">1</option>
					  <option  value ="2">2</option>
					  <option  value ="3">3</option>
					  <option  value ="4">4</option>
					  <option  value ="5">5</option>
					  <option  value ="6">6</option>
					  <option  value ="7">7</option>
					  <option  value ="8">8</option>
			</select>
		</div>
		<div class="fitem">
			<label>拍摄间隔：</label><input name="executionTime" maxlength="3" class="easyui-validatebox textbox">(秒)
		</div>
		<div class="fitem">
			<label>拍摄数量：</label><input name="totalPicture" maxlength="3" class="easyui-validatebox textbox">
		</div>
		
		<div class="fitem">
			<label>保存标识：</label><select name="saveFlag" class="easyui-validatebox textbox" required="true">
					  <option  value ="0">实时上传</option>
					  <option  value ="1">终端保存</option>
			</select>
		</div>
		<div class="fitem">
			<label>分辨率：</label><select name="resolution" class="easyui-validatebox textbox" required="true">
					 <option value="1">320*240</option>
					 <option value="2">640*480</option>
					 <option value="3">800*600</option>
					 <option value="4">1024*768</option>
					 <option value="5">176*144</option>
					 <option value="6">352*288</option>
					 <option value="7">704*288</option>
					 <option value="8">704*576</option>
			</select>
		</div>
		<div class="fitem">
			<label>图片质量：</label><select name="quality" class="easyui-validatebox textbox" required="true">
					 <option value="1">1</option>
					 <option value="2">2</option>
					 <option value="3">3</option>
					 <option value="4">4</option>
					 <option value="5">5</option>
					 <option value="6">6</option>
					 <option value="7">7</option>
					 <option value="8">8</option>
					 <option value="9">9</option>
					 <option value="10">10</option>
			</select>(值越小越高)
		</div>
		<div class="fitem">
			<label>亮度：</label><input name="luminance" value="127" maxlength="3" class="easyui-validatebox textbox">(0~255)
		</div>
		<div class="fitem">
			<label>对比度：</label><input name="contrast"  value="10" maxlength="3" class="easyui-validatebox textbox">(0~127)
		</div>
		<div class="fitem">
			<label>饱和度：</label><input name="saturation" value="10" maxlength="3" class="easyui-validatebox textbox">(0~127)
		</div>
		<div class="fitem">
			<label>色度：</label><input name="chromaticity"  value="127" maxlength="3" class="easyui-validatebox textbox">(0~255)
		</div>
	</form>
</div>
<div id="send-take-many-picture-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>


<div id="send-stop-take-picture-cmd-dlg"  class="easyui-dialog" title="停止拍摄" style="width: 400px; height: 170px; padding: 10px 20px" closed="true" buttons="#send-stop-take-picture-cmd-dlg-buttons">
	<form id="send-stop-take-picture-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-stop-take-picture-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8801">
		<input name="commandType" type="hidden" value="0">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-stop-take-picture-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>拍摄通道：</label><select name="channelId" class="easyui-validatebox textbox" required="true" missingMessage="调用哪个摄像头">
					  <option  value ="1">1</option>
					  <option  value ="2">2</option>
					  <option  value ="3">3</option>
					  <option  value ="4">4</option>
					  <option  value ="5">5</option>
					  <option  value ="6">6</option>
					  <option  value ="7">7</option>
					  <option  value ="8">8</option>
			</select>
		</div>
	</form>
</div>
<div id="send-stop-take-picture-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>


<div id="send-take-video-cmd-dlg"  class="easyui-dialog" title="录像采集" style="width: 520px; height: 475px; padding: 10px 20px" closed="true" buttons="#send-take-video-cmd-dlg-buttons">
	<form id="send-take-video-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-take-video-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8801">
		<input name="commandType" type="hidden" value="1">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-take-video-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>录像通道：</label><select name="channelId" class="easyui-validatebox textbox" required="true" missingMessage="调用哪个摄像头录像">
					  <option  value ="1">1</option>
					  <option  value ="2">2</option>
					  <option  value ="3">3</option>
					  <option  value ="4">4</option>
					  <option  value ="5">5</option>
					  <option  value ="6">6</option>
					  <option  value ="7">7</option>
					  <option  value ="8">8</option>
			</select>
		</div>
		<div class="fitem">
			<label>录像时间：</label><input name="executionTime" maxlength="5" class="easyui-validatebox textbox">(秒,0表示一直录像)
		</div>
		
		<div class="fitem">
			<label>保存标识：</label><select name="saveFlag" class="easyui-validatebox textbox" required="true">
					  <option  value ="0">实时上传</option>
					  <option  value ="1">终端保存</option>
			</select>
		</div>
		<div class="fitem">
			<label>分辨率：</label><select name="resolution" class="easyui-validatebox textbox" required="true">
					 <option value="1">320*240</option>
					 <option value="2">640*480</option>
					 <option value="3">800*600</option>
					 <option value="4">1024*768</option>
					 <option value="5">176*144</option>
					 <option value="6">352*288</option>
					 <option value="7">704*288</option>
					 <option value="8">704*576</option>
			</select>
		</div>
		<div class="fitem">
			<label>图片质量：</label><select name="quality" class="easyui-validatebox textbox" required="true">
					 <option value="1">1</option>
					 <option value="2">2</option>
					 <option value="3">3</option>
					 <option value="4">4</option>
					 <option value="5">5</option>
					 <option value="6">6</option>
					 <option value="7">7</option>
					 <option value="8">8</option>
					 <option value="9">9</option>
					 <option value="10">10</option>
			</select>(值越小越高)
		</div>
		<div class="fitem">
			<label>亮度：</label><input name="luminance" value="127" maxlength="3" class="easyui-validatebox textbox">(0~255)
		</div>
		<div class="fitem">
			<label>对比度：</label><input name="contrast"  value="10" maxlength="3" class="easyui-validatebox textbox">(0~127)
		</div>
		<div class="fitem">
			<label>饱和度：</label><input name="saturation" value="10" maxlength="3" class="easyui-validatebox textbox">(0~127)
		</div>
		<div class="fitem">
			<label>色度：</label><input name="chromaticity"  value="127" maxlength="3" class="easyui-validatebox textbox">(0~255)
		</div>
	</form>
</div>
<div id="send-take-video-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>

<div id="send-media-data-query-cmd-dlg"  class="easyui-dialog" title="存储多媒体数据检索 " style="width:480px; height:300px; padding: 10px 20px" closed="true" buttons="#send-media-data-query-cmd-dlg-buttons">
	<form id="send-media-data-query-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-media-data-query-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8802">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-media-data-query-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>多媒体类型：</label><select name="mediatype" class="easyui-validatebox textbox" required="true">
					  <option  value ="0">图像</option>
					  <option  value ="1">音频</option>
					  <option  value ="2">视频</option>
			</select>
		</div>
		<div class="fitem">
			<label>拍摄通道：</label><select name="channelId" class="easyui-validatebox textbox" required="true" missingMessage="调用哪个摄像头录像">
					  <option  value ="0">所有通道</option>
					  <option  value ="1">1</option>
					  <option  value ="2">2</option>
					  <option  value ="3">3</option>
					  <option  value ="4">4</option>
					  <option  value ="5">5</option>
					  <option  value ="6">6</option>
					  <option  value ="7">7</option>
					  <option  value ="8">8</option>
			</select>
		</div>
		
		<div class="fitem">
			<label>事件项编码：</label><select name="eventCode" class="easyui-validatebox textbox" required="true">
					 <option value="0">平台下发指令</option>
					 <option value="1">定时动作</option>
					 <option value="2">抢劫报警触发</option>
					 <option value="3">碰撞侧翻报警触发</option>
			</select>
		</div>
		<div class="fitem">
			<label>查询时间：</label><input name="startTime" class="easyui-datetimebox" style="width:120px">至<input name="endTime"  class="easyui-datetimebox" style="width:120px">
		</div>
	</form>
</div>
<div id="send-media-data-query-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>


<div id="send-media-data-upload-cmd-dlg"  class="easyui-dialog" title="存储多媒体数据上传命令  " style="width: 480px; height: 300px; padding: 10px 20px" closed="true" buttons="#send-media-data-upload-cmd-dlg-buttons">
	<form id="send-media-data-upload-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-media-data-upload-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8803">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-media-data-upload-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>多媒体类型：</label><select name="mediatype" class="easyui-validatebox textbox" required="true">
					  <option  value ="0">图像</option>
					  <option  value ="1">音频</option>
					  <option  value ="2">视频</option>
			</select>
		</div>
		<div class="fitem">
			<label>拍摄通道：</label><select name="channelId" class="easyui-validatebox textbox" required="true" missingMessage="调用哪个摄像头录像">
					  <option  value ="0">所有通道</option>
					  <option  value ="1">1</option>
					  <option  value ="2">2</option>
					  <option  value ="3">3</option>
					  <option  value ="4">4</option>
					  <option  value ="5">5</option>
					  <option  value ="6">6</option>
					  <option  value ="7">7</option>
					  <option  value ="8">8</option>
			</select>
		</div>
		
		<div class="fitem">
			<label>事件项编码：</label><select name="eventCode" class="easyui-validatebox textbox" required="true">
					 <option value="0">平台下发指令</option>
					 <option value="1">定时动作</option>
					 <option value="2">抢劫报警触发</option>
					 <option value="3">碰撞侧翻报警触发</option>
			</select>
		</div>
		<div class="fitem">
			<label>保存标识：</label><select name="saveFlag" class="easyui-validatebox textbox" required="true">
					  <option  value ="0">保留</option>
					  <option  value ="1">删除</option>
			</select>
		</div>
		<div class="fitem">
			<label>查询时间：</label><input name="startTime" class="easyui-datetimebox" style="width:120px">至<input name="endTime"  class="easyui-datetimebox" style="width:120px">
		</div>
	</form>
</div>
<div id="send-media-data-upload-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>


<div id="send-one-media-data-upload-cmd-dlg"  class="easyui-dialog" title="单条存储多媒体数据检索上传命令" style="width: 400px; height: 200px; padding: 10px 20px" closed="true" buttons="#send-one-media-data-upload-cmd-dlg-buttons">
	<form id="send-one-media-data-upload-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-one-media-data-upload-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8805">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-one-media-data-upload-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>多媒体id：</label><input name="mediaDataId"  class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>保存标识：</label><select name="saveFlag" class="easyui-validatebox textbox" required="true">
					  <option  value ="0">保留</option>
					  <option  value ="1">删除</option>
			</select>
		</div>
	</form>
</div>
<div id="send-one-media-data-upload-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>

<div id="send-text-info-2013-cmd-dlg"  class="easyui-dialog" title="文本信息下发 " style="width:650px; height:550px; padding: 10px 20px" closed="true" buttons="#send-text-info-2013-cmd-dlg-buttons">
	<form id="send-text-info-2013-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-text-info-2013-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8300">
		<div class="fitem">
			<label style="width:100px;">设备名称：</label><input name="name" id="send-text-info-2013-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label style="width:100px;">紧急：</label><select name="urgency" class="easyui-validatebox textbox" required="true">
					  <option  value ="0">是</option>
					  <option  value ="1">否</option>
			</select>
		</div>
		<div class="fitem">
			<label style="width:100px;">终端显示屏显示：</label><select name="display" class="easyui-validatebox textbox" required="true">
					  <option  value ="0">是</option>
					  <option  value ="1">否</option>
			</select>
		</div>
		<div class="fitem">
			<label style="width:100px;">终端TTS播读：</label><select name="ttsread" class="easyui-validatebox textbox" required="true">
					  <option  value ="0">是</option>
					  <option  value ="1">否</option>
			</select>
		</div>
		<div class="fitem">
			<label style="width:100px;">广告屏显示：</label><select name="advertdisplay" class="easyui-validatebox textbox" required="true">
					 <option  value ="0">是</option>
					 <option  value ="1">否</option>
			</select>
		</div>
		<div class="fitem">
			<label style="width:100px;">信息类型：</label><select name="type" class="easyui-validatebox textbox" required="true">
					 <option  value ="0">中心导航信息</option>
					  <option  value ="1">CAN故障码信息</option>
			</select>
		</div>
		<div class="fitem">
			<label style="width:100px;">文本信息：</label><textarea  name="text"  style="height:200px;width:380px;" class="easyui-validatebox textbox" required="true"/></textarea>
		</div>
	</form>
</div>
<div id="send-text-info-2013-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="send2013TextCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>


<div id="send-text-info-2011-cmd-dlg"  class="easyui-dialog" title="文本信息下发 " style="width:650px; height: 530px; padding: 10px 20px" closed="true" buttons="#send-text-info-2011-cmd-dlg-buttons">
	<form id="send-text-info-2011-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-text-info-2011-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8300">
		<div class="fitem">
			<label style="width:100px;">设备名称：</label><input name="name" id="send-text-info-2011-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label style="width:100px;">紧急：</label><select name="urgency" class="easyui-validatebox textbox" required="true">
					  <option  value ="0">是</option>
					  <option  value ="1">否</option>
			</select>
		</div>
		<div class="fitem">
			<label style="width:100px;">终端显示屏显示：</label><select name="display" class="easyui-validatebox textbox" required="true">
					  <option  value ="0">是</option>
					  <option  value ="1">否</option>
			</select>
		</div>
		<div class="fitem">
			<label style="width:100px;">终端TTS播读：</label><select name="ttsread" class="easyui-validatebox textbox" required="true">
					  <option  value ="0">是</option>
					  <option  value ="1">否</option>
			</select>
		</div>
		<div class="fitem">
			<label style="width:100px;">广告屏显示：</label><select name="advertdisplay" class="easyui-validatebox textbox" required="true">
					 <option  value ="0">是</option>
					 <option  value ="1">否</option>
			</select>
		</div>
		<div class="fitem">
			<label style="width:100px;">文本信息：</label><textarea  name="text"  style="height:200px;width:380px;" class="easyui-validatebox textbox" required="true"/></textarea>
		</div>
	</form>
</div>
<div id="send-text-info-2011-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="send2011TextCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>

<div id="send-text-info-service-cmd-dlg"  class="easyui-dialog" title="信息服务 " style="width:550px; height: 410px; padding: 10px 20px" closed="true" buttons="#send-text-info-service-cmd-dlg-buttons">
	<form id="send-text-info-service-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-text-info-service-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8304">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-text-info-service-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>信息类型：</label><select name="type" class="easyui-validatebox textbox" required="true">
				  <option value="0">新闻</option>
                  <option value="1">天气</option>
                  <option value="2">娱乐</option>
                  <option value="3">广告</option>
                  <option value="4">其他</option>
			</select>
		</div>
		<div class="fitem">
			<label>信息内容：</label><textarea  name="info"  style="height:200px;width:380px;" class="easyui-validatebox textbox" required="true"/></textarea>
		</div>
	</form>
</div>
<div id="send-text-info-service-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>

<div id="send-location-temporary-query-cmd-dlg"  class="easyui-dialog" title="临时位置跟踪控制" style="width: 500px; height: 230px; padding: 10px 20px" closed="true" buttons="#send-location-temporary-query-cmd-dlg-buttons">
	<form id="send-location-temporary-query-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-location-temporary-query-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8202">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-location-temporary-query-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>时间间隔：</label><input name="interval" maxlength="5" class="easyui-validatebox textbox" required="true">(秒，0表示停止跟踪)
		</div>
		<div class="fitem">
			<label>位置跟踪有效期：</label><input name="expTime" maxlength="8" class="easyui-validatebox textbox" required="true">(秒)
		</div>
	</form>
</div>
<div id="send-location-temporary-query-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendTestCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>


<div id="send-terminal-parameter-query-cmd-dlg"  class="easyui-dialog" title="查询终端参数 " style="width: 400px; height: 135px; padding: 10px 20px" closed="true" buttons="#send-terminal-parameter-query-cmd-dlg-buttons">
	<form id="send-terminal-parameter-query-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-terminal-parameter-query-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8104">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-terminal-parameter-query-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
	</form>
</div>
<div id="send-terminal-parameter-query-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>

<div id="send-terminal-control-shutdown-cmd-dlg"  class="easyui-dialog" title="终端关机指令 " style="width: 400px; height: 135px; padding: 10px 20px" closed="true" buttons="#send-terminal-control-shutdown-cmd-dlg-buttons">
	<form id="send-terminal-control-shutdown-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-terminal-control-shutdown-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8105">
		<input name="commandWord" type="hidden" value="3">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-terminal-control-shutdown-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
	</form>
</div>
<div id="send-terminal-control-shutdown-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>

<div id="send-terminal-control-reset-cmd-dlg"  class="easyui-dialog" title="终端复位 " style="width: 400px; height: 135px; padding: 10px 20px" closed="true" buttons="#send-terminal-control-reset-cmd-dlg-buttons">
	<form id="send-terminal-control-reset-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-terminal-control-reset-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8105">
		<input name="commandWord" type="hidden" value="4">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-terminal-control-reset-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
	</form>
</div>
<div id="send-terminal-control-reset-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>

<div id="send-terminal-control-reset-factory-setting-cmd-dlg"  class="easyui-dialog" title="终端恢复出厂设置 " style="width: 400px; height: 135px; padding: 10px 20px" closed="true" buttons="#send-terminal-control-reset-factory-setting-cmd-dlg-buttons">
	<form id="send-terminal-control-reset-factory-setting-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-terminal-control-reset-factory-setting-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8105">
		<input name="commandWord" type="hidden" value="5">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-terminal-control-reset-factory-setting-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
	</form>
</div>
<div id="send-terminal-control-reset-factory-setting-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>

<div id="send-terminal-control-turn-off-data-communication-cmd-dlg"  class="easyui-dialog" title="关闭数据通信 " style="width: 400px; height: 135px; padding: 10px 20px" closed="true" buttons="#send-terminal-control-turn-off-data-communication-cmd-dlg-buttons">
	<form id="send-terminal-control-turn-off-data-communication-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-terminal-control-turn-off-data-communication-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8105">
		<input name="commandWord" type="hidden" value="6">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-terminal-control-turn-off-data-communication-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
	</form>
</div>
<div id="send-terminal-control-turn-off-data-communication-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>

<div id="send-terminal-control-turn-off-wireless-communication-cmd-dlg"  class="easyui-dialog" title="关闭所有无线通信 " style="width: 400px; height: 135px; padding: 10px 20px" closed="true" buttons="#send-terminal-control-turn-off-wireless-communication-cmd-dlg-buttons">
	<form id="send-terminal-control-turn-off-wireless-communication-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-terminal-control-turn-off-wireless-communication-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8105">
		<input name="commandWord" type="hidden" value="7">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-terminal-control-turn-off-wireless-communication-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
	</form>
</div>
<div id="send-terminal-control-turn-off-wireless-communication-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>


<!-- 终端参数设置开始 -->
<div id="send-terminal-parameter-heartbeat-cmd-dlg"  class="easyui-dialog" title="心跳间隔 " style="width: 400px; height: 180px; padding: 10px 20px" closed="true" buttons="#send-terminal-parameter-heartbeat-cmd-dlg-buttons">
	<form id="send-terminal-parameter-heartbeat-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-terminal-parameter-heartbeat-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8103">
		<input name="paramkeys" type="hidden" value="d_0001">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-terminal-parameter-heartbeat-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>时间间隔：</label><input name="d_0001" maxlength="3" class="easyui-validatebox textbox" required="true" validType="integer">(秒)
		</div>
	</form>
</div>
<div id="send-terminal-parameter-heartbeat-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendTerminalParameterSettingCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>



<div id="send-terminal-parameter-report-strategy-cmd-dlg"  class="easyui-dialog" title="汇报策略 " style="width: 560px; height: 520px; padding: 10px 20px" closed="true" buttons="#send-terminal-parameter-report-strategy-cmd-dlg-buttons">
	<form id="send-terminal-parameter-report-strategy-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-terminal-parameter-report-strategy-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8103">
		<input name="paramkeys" type="hidden" value="d_0029,d_002C,d_0020,d_0021,d_0028,d_002F,d_0022,d_0027,d_002E">
		<div class="fitem">
			<label style="width:170px;">设备名称：</label><input name="name" id="send-terminal-parameter-report-strategy-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label style="width:170px;">缺省汇报时间间隔：</label><input name="d_0029" maxlength="3" class="easyui-validatebox textbox" validType="integer">(秒)
		</div>
		<div class="fitem">
			<label style="width:170px;">缺省汇报距离间隔：</label><input name="d_002C" maxlength="3" class="easyui-validatebox textbox" validType="integer">(米)
		</div>
		<div class="fitem">
			<label style="width:170px;">位置汇报策略：</label><select name="d_0020" >
					         	<option value="">请选择</option>
					         	<option value="0">定时汇报</option>
					         	<option value="1">定距汇报</option>
					         	<option value="2">定时和定距汇报</option>
					        </select>
		</div>
		<div class="fitem">
			<label style="width:170px;">位置汇报方案：</label><select name="d_0021">
					         	<option value="">请选择</option>
					         	<option value="0">根据ACC状态</option>
					         	<option value="1">根据登录状态和ACC状态</option>
					        </select>
		</div>
		<div class="fitem">
			<label style="width:170px;">紧急报警时汇报时间间隔：</label><input name="d_0028" maxlength="3" class="easyui-validatebox textbox"  validType="integer">(秒)
		</div>
		<div class="fitem">
			<label style="width:170px;">紧急报警时汇报距离间隔：</label><input name="d_002F" maxlength="3" class="easyui-validatebox textbox"  validType="integer">(米)
		</div>
		<div class="fitem">
			<label style="width:170px;">驾驶员未登录汇报时间间隔：</label><input name="d_0022" maxlength="3" class="easyui-validatebox textbox"  validType="integer">(秒)
		</div>
		<div class="fitem">
			<label style="width:170px;">驾驶员未登录汇报距离间隔：</label><input name="d_002D" maxlength="3" class="easyui-validatebox textbox"  validType="integer">(米)
		</div>
		<!--  
		<div class="fitem">
			<label>空车汇报时间间隔：</label><input name="d_0001" maxlength="3" class="easyui-validatebox textbox" required="true" validType="integer">(秒)
		</div>
		<div class="fitem">
			<label>空车汇报距离间隔：</label><input name="d_0001" maxlength="3" class="easyui-validatebox textbox" required="true" validType="integer">(米)
		</div>
		<div class="fitem">
			<label>重车汇报时间间隔：</label><input name="d_0001" maxlength="3" class="easyui-validatebox textbox" required="true" validType="integer">(秒)
		</div>
		<div class="fitem">
			<label>重车汇报距离间隔：</label><input name="d_0001" maxlength="3" class="easyui-validatebox textbox" required="true" validType="integer">(米)
		</div>-->
		<div class="fitem">
			<label style="width:170px;">休眠时汇报时间间隔：</label><input name="d_0027" maxlength="3" class="easyui-validatebox textbox" validType="integer">(秒)
		</div>
		<div class="fitem">
			<label style="width:170px;">休眠时汇报距离间隔：</label><input name="d_002E" maxlength="3" class="easyui-validatebox textbox"  validType="integer">(米)
		</div>
	</form>
</div>
<div id="send-terminal-parameter-report-strategy-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendTerminalParameterSettingCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>

<!-- 终端参数设置开始 结束-->


<!-- 行驶记录仪数据采集开始 -->
<div id="send-dvr2003-data-driver-info-cmd-dlg"  class="easyui-dialog" title="驾驶员信息" style="width: 400px; height: 135px; padding: 10px 20px" closed="true" buttons="#send-dvr2003-data-driver-info-cmd-dlg-buttons">
	<form id="send-dvr2003-data-driver-info-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-dvr2003-data-driver-info-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8700">
		<input name="commandWord" type="hidden" value="01H">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-dvr2003-data-driver-info-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
	</form>
</div>
<div id="send-dvr2003-data-driver-info-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>


<div id="send-dvr2003-data-timestamp-cmd-dlg"  class="easyui-dialog" title="记录仪时钟" style="width: 400px; height: 135px; padding: 10px 20px" closed="true" buttons="#send-dvr2003-data-timestamp-cmd-dlg-buttons">
	<form id="send-dvr2003-data-timestamp-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-dvr2003-data-timestamp-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8700">
		<input name="commandWord" type="hidden" value="02H">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-dvr2003-data-timestamp-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
	</form>
</div>
<div id="send-dvr2003-data-timestamp-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>


<div id="send-dvr2003-data-car-info-cmd-dlg"  class="easyui-dialog" title="车辆信息" style="width: 400px; height: 135px; padding: 10px 20px" closed="true" buttons="#send-dvr2003-data-car-info-cmd-dlg-buttons">
	<form id="send-dvr2003-data-car-info-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-dvr2003-data-car-info-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8700">
		<input name="commandWord" type="hidden" value="06H">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-dvr2003-data-car-info-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
	</form>
</div>
<div id="send-dvr2003-data-car-info-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>

<div id="send-dvr2003-data-car-coefficient-cmd-dlg"  class="easyui-dialog" title="车辆特征系数" style="width: 400px; height: 135px; padding: 10px 20px" closed="true" buttons="#send-dvr2003-data-car-coefficient-cmd-dlg-buttons">
	<form id="send-dvr2003-data-car-coefficient-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-dvr2003-data-car-coefficient-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8700">
		<input name="commandWord" type="hidden" value="04H">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-dvr2003-data-car-coefficient-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
	</form>
</div>
<div id="send-dvr2003-data-car-coefficient-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>


<div id="send-dvr2003-data-360h-mileage-cmd-dlg"  class="easyui-dialog" title="最近306h内行驶里程" style="width: 400px; height: 135px; padding: 10px 20px" closed="true" buttons="#send-dvr2003-data-360h-mileage-cmd-dlg-buttons">
	<form id="send-dvr2003-data-360h-mileage-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-dvr2003-data-360h-mileage-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8700">
		<input name="commandWord" type="hidden" value="03H">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-dvr2003-data-360h-mileage-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
	</form>
</div>
<div id="send-dvr2003-data-360h-mileage-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>


<div id="send-dvr2003-data-48h-mileage-cmd-dlg"  class="easyui-dialog" title="最近两个日历天内行驶里程" style="width: 400px; height: 135px; padding: 10px 20px" closed="true" buttons="#send-dvr2003-data-48h-mileage-cmd-dlg-buttons">
	<form id="send-dvr2003-data-48h-mileage-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-dvr2003-data-48h-mileage-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8700">
		<input name="commandWord" type="hidden" value="08H">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-dvr2003-data-48h-mileage-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
	</form>
</div>
<div id="send-dvr2003-data-48h-mileage-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>

<div id="send-dvr2003-data-360h-speed-cmd-dlg"  class="easyui-dialog" title="最近306h内行驶速度" style="width: 400px; height: 135px; padding: 10px 20px" closed="true" buttons="#send-dvr2003-data-360h-speed-cmd-dlg-buttons">
	<form id="send-dvr2003-data-360h-speed-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-dvr2003-data-360h-speed-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8700">
		<input name="commandWord" type="hidden" value="05H">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-dvr2003-data-360h-speed-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
	</form>
</div>
<div id="send-dvr2003-data-360h-speed-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>

<div id="send-dvr2003-data-48h-speed-cmd-dlg"  class="easyui-dialog" title="最近两个日历天内行驶速度" style="width: 400px; height: 135px; padding: 10px 20px" closed="true" buttons="#send-dvr2003-data-48h-speed-cmd-dlg-buttons">
	<form id="send-dvr2003-data-48h-speed-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-dvr2003-data-48h-speed-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8700">
		<input name="commandWord" type="hidden" value="09H">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-dvr2003-data-48h-speed-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
	</form>
</div>
<div id="send-dvr2003-data-48h-speed-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>

<div id="send-dvr2003-data-driver-accident-place-cmd-dlg"  class="easyui-dialog" title="最近10个事故疑点" style="width: 400px; height: 135px; padding: 10px 20px" closed="true" buttons="#send-dvr2003-data-driver-accident-place-cmd-dlg-buttons">
	<form id="send-dvr2003-data-driver-accident-place-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-dvr2003-data-driver-accident-place-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8700">
		<input name="commandWord" type="hidden" value="07H">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-dvr2003-data-driver-accident-place-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
	</form>
</div>
<div id="send-dvr2003-data-driver-accident-place-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>

<div id="send-dvr2003-data-drowsy-driving-cmd-dlg"  class="easyui-dialog" title="疲劳驾驶" style="width: 400px; height: 135px; padding: 10px 20px" closed="true" buttons="#send-dvr2003-data-drowsy-driving-cmd-dlg-buttons">
	<form id="send-dvr2003-data-drowsy-driving-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-dvr2003-data-drowsy-driving-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8700">
		<input name="commandWord" type="hidden" value="11H">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-dvr2003-data-drowsy-driving-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
	</form>
</div>
<div id="send-dvr2003-data-drowsy-driving-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>

<!-- 行驶记录仪数据采集结束 -->

<div id="send-test-cmd-dlg"  class="easyui-dialog" title="指令测试" style="width: 580px; height: 400px; padding: 10px 20px" closed="true" buttons="#send-test-cmd-dlg-buttons">
	<form id="send-test-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-test-cmd-dlg-frm-deviceId" type="hidden">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-test-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>消息ID：</label><input name="messageId" value="8500" class="easyui-validatebox textbox" required="true">
		</div>
		<div class="fitem">
			<label>消息体：</label><textarea  id="send-test-cmd-dlg-frm-messageBody"  style="height:200px;width:380px;" class="easyui-validatebox textbox" required="true"/>{"flag":"10000000"}</textarea>
		</div>
	</form>
</div>

<div id="send-test-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendTestCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>

<div id="send-set-rail-circle-cmd-dlg"  class="easyui-dialog" title="设置圆形区域" style="width:450px;height:400px; padding:10px 20px" closed="true" buttons="#send-set-rail-circle-cmd-dlg-buttons">
	<form id="send-set-rail-circle-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-set-rail-circle-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8600">
		<div class="fitem">
			<label style="width:100px;">设备名称：</label><input name="name" id="send-set-rail-circle-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label style="width:100px;">圆形区域：</label><select id="send-set-rail-circle-cmd-dlg-frm-rail" class="easyui-validatebox textbox" required="true">
			</select>
		</div>
		<div class="fitem">
			<label style="width:100px;">围栏限速：</label><input name="limitedSpeed"  maxlength="3"  class="easyui-validatebox textbox" required="true" missingMessage="围栏内超过此速度告警" validType="integer">
		</div>
		<div class="fitem">
			<label style="width:100px;">超速持续时间：</label><input name="durationTime"  maxlength="3" value="60" class="easyui-validatebox textbox" required="true"  missingMessage="围栏内超速持续时间超过告警" validType="integer">(秒)
		</div>
		<div class="fitem">
			<label style="width:100px;">区域属性：</label><input type="checkbox" class="textbox" style="width:15px;" name="attribute" value="0" >根据时间
			<input type="checkbox" class="textbox" style="width:15px;" name="attribute" value="1" >限速 
			<input type="checkbox" class="textbox" style="width:15px;" name="attribute" value="2" >进区域报警给驾驶员
			<input type="checkbox" class="textbox" style="width:15px;" name="attribute" value="3" >进区域报警给平台
			<input type="checkbox" class="textbox" style="width:15px;" name="attribute" value="4" >出区域报警给驾驶员 
			<input type="checkbox" class="textbox" style="width:15px;" name="attribute" value="5" >出区域报警给平台
			<input type="checkbox" class="textbox" style="width:15px;" name="attribute" value="8" >禁止开门
			<input type="checkbox" class="textbox" style="width:15px;" name="attribute" value="14" >进区域关闭通信模块
			<input type="checkbox" class="textbox" style="width:15px;" name="attribute" value="15" >进区域采集GNSS详细定位数据 
		</div>
		<div class="fitem">
			<label style="width:100px;">开始时间：</label><input class="easyui-datetimebox" name="startTime" editable="false" data-options="required:true" missingMessage="设置有效开始时间">
		</div>
		<div class="fitem">
			<label style="width:100px;">结束时间：</label><input class="easyui-datetimebox" name="endTime" editable="false" data-options="required:true"  missingMessage="设置有效结束时间">
		</div>
	</form>
</div>
<div id="send-set-rail-circle-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendSetCircleRailCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>


<div id="send-del-rail-circle-cmd-dlg"  class="easyui-dialog" title="删除圆形区域" style="width:450px;height:200px; padding:10px 20px" closed="true" buttons="#send-del-rail-circle-cmd-dlg-buttons">
	<form id="send-del-rail-circle-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-del-rail-circle-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8601">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-del-rail-circle-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>圆形区域：</label><select name="areaId" id="send-del-rail-circle-cmd-dlg-frm-areaId" class="easyui-validatebox textbox" required="true">
				<option value="">全部区域</option>
			</select>
		</div>
	</form>
</div>
<div id="send-del-rail-circle-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendDelRailCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>


<div id="send-set-rail-rectangle-cmd-dlg"  class="easyui-dialog" title="设置矩形区域" style="width:450px;height:400px; padding:10px 20px" closed="true" buttons="#send-set-rail-rectangle-cmd-dlg-buttons">
	<form id="send-set-rail-rectangle-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-set-rail-rectangle-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8602">
		<div class="fitem">
			<label  style="width:100px;">设备名称：</label><input name="name" id="send-set-rail-rectangle-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label  style="width:100px;">矩形区域：</label><select id="send-set-rail-rectangle-cmd-dlg-frm-rail" class="easyui-validatebox textbox" required="true">
			</select>
		</div>
		<div class="fitem">
			<label style="width:100px;">围栏限速：</label><input name="limitedSpeed"  maxlength="3"  class="easyui-validatebox textbox" required="true" missingMessage="围栏内超过此速度告警" validType="integer">
		</div>
		<div class="fitem">
			<label style="width:100px;">超速持续时间：</label><input name="durationTime"  maxlength="3" value="60" class="easyui-validatebox textbox" required="true"  missingMessage="围栏内超速持续时间超过告警" validType="integer">(秒)
		</div>
		<div class="fitem">
			<label style="width:100px;">区域属性：</label><input type="checkbox" class="textbox" style="width:15px;" name="attribute" value="0" >根据时间
			<input type="checkbox" class="textbox" style="width:15px;" name="attribute" value="1" >限速 
			<input type="checkbox" class="textbox" style="width:15px;" name="attribute" value="2" >进区域报警给驾驶员
			<input type="checkbox" class="textbox" style="width:15px;" name="attribute" value="3" >进区域报警给平台
			<input type="checkbox" class="textbox" style="width:15px;" name="attribute" value="4" >出区域报警给驾驶员 
			<input type="checkbox" class="textbox" style="width:15px;" name="attribute" value="5" >出区域报警给平台
			<input type="checkbox" class="textbox" style="width:15px;" name="attribute" value="8" >禁止开门
			<input type="checkbox" class="textbox" style="width:15px;" name="attribute" value="14" >进区域关闭通信模块
			<input type="checkbox" class="textbox" style="width:15px;" name="attribute" value="15" >进区域采集GNSS详细定位数据 
		</div>
		<div class="fitem">
			<label style="width:100px;">开始时间：</label><input class="easyui-datetimebox" name="startTime" editable="false" data-options="required:true" missingMessage="设置有效开始时间">
		</div>
		<div class="fitem">
			<label style="width:100px;">结束时间：</label><input class="easyui-datetimebox" name="endTime" editable="false" data-options="required:true"  missingMessage="设置有效结束时间">
		</div>
	</form>
</div>
<div id="send-set-rail-rectangle-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendSetRectangleRailCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>

<div id="send-del-rail-rectangle-cmd-dlg"  class="easyui-dialog" title="删除矩形区域" style="width:450px;height:200px; padding:10px 20px" closed="true" buttons="#send-del-rail-rectangle-cmd-dlg-buttons">
	<form id="send-del-rail-rectangle-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-del-rail-rectangle-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8603">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-del-rail-rectangle-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>矩形区域：</label><select name="areaId" id="send-del-rail-rectangle-cmd-dlg-frm-areaId" class="easyui-validatebox textbox" required="true">
			<option value="">全部区域</option>
			</select>
		</div>
	</form>
</div>
<div id="send-del-rail-rectangle-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendDelRailCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>



<div id="send-set-rail-polygon-cmd-dlg"  class="easyui-dialog" title="设置多边形区域" style="width:450px;height:400px; padding:10px 20px" closed="true" buttons="#send-set-rail-polygon-cmd-dlg-buttons">
	<form id="send-set-rail-polygon-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-set-rail-polygon-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8604">
		<div class="fitem">
			<label style="width:100px;">设备名称：</label><input name="name" id="send-set-rail-polygon-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label style="width:100px;">多边形区域：</label><select id="send-set-rail-polygon-cmd-dlg-frm-rail" class="easyui-validatebox textbox" required="true">
			</select>
		</div>
		<div class="fitem">
			<label style="width:100px;">围栏限速：</label><input name="limitedSpeed"  maxlength="3"  class="easyui-validatebox textbox" required="true" missingMessage="围栏内超过此速度告警" validType="integer">
		</div>
		<div class="fitem">
			<label style="width:100px;">超速持续时间：</label><input name="durationTime"  maxlength="3" value="60" class="easyui-validatebox textbox" required="true"  missingMessage="围栏内超速持续时间超过告警" validType="integer">(秒)
		</div>
		<div class="fitem">
			<label style="width:100px;">区域属性：</label><input type="checkbox" class="textbox" style="width:15px;" name="attribute" value="0" >根据时间
			<input type="checkbox" class="textbox" style="width:15px;" name="attribute" value="1" >限速 
			<input type="checkbox" class="textbox" style="width:15px;" name="attribute" value="2" >进区域报警给驾驶员
			<input type="checkbox" class="textbox" style="width:15px;" name="attribute" value="3" >进区域报警给平台
			<input type="checkbox" class="textbox" style="width:15px;" name="attribute" value="4" >出区域报警给驾驶员 
			<input type="checkbox" class="textbox" style="width:15px;" name="attribute" value="5" >出区域报警给平台
			<input type="checkbox" class="textbox" style="width:15px;" name="attribute" value="8" >禁止开门
			<input type="checkbox" class="textbox" style="width:15px;" name="attribute" value="14" >进区域关闭通信模块
			<input type="checkbox" class="textbox" style="width:15px;" name="attribute" value="15" >进区域采集GNSS详细定位数据 
		</div>
		<div class="fitem">
			<label style="width:100px;">开始时间：</label><input class="easyui-datetimebox" name="startTime" editable="false" data-options="required:true" missingMessage="设置有效开始时间">
		</div>
		<div class="fitem">
			<label style="width:100px;">结束时间：</label><input class="easyui-datetimebox" name="endTime" editable="false" data-options="required:true"  missingMessage="设置有效结束时间">
		</div>
	</form>
</div>
<div id="send-set-rail-polygon-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendSetPolygonRailCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>

<div id="send-del-rail-polygon-cmd-dlg"  class="easyui-dialog" title="删除多边形区域" style="width:450px;height:200px; padding:10px 20px" closed="true" buttons="#send-del-rail-polygon-cmd-dlg-buttons">
	<form id="send-del-rail-polygon-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-del-rail-polygon-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8605">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-del-rail-polygon-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>多边形区域：</label><select name="areaId" id="send-del-rail-polygon-cmd-dlg-frm-areaId" class="easyui-validatebox textbox" required="true">
			<option value="">全部区域</option>
			</select>
		</div>
	</form>
</div>
<div id="send-del-rail-polygon-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendDelRailCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>



<div id="send-set-rail-route-cmd-dlg"  class="easyui-dialog" title="设置路线" style="width:450px;height:200px; padding:10px 20px" closed="true" buttons="#send-set-rail-route-cmd-dlg-buttons">
	<form id="send-set-rail-route-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-set-rail-route-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8606">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-set-rail-route-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>路线：</label><select id="send-set-rail-route-cmd-dlg-frm-rail" class="easyui-validatebox textbox" required="true">
			</select>
		</div>
	</form>
</div>
<div id="send-set-rail-route-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendSetRouteRailCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>

<div id="send-del-rail-route-cmd-dlg"  class="easyui-dialog" title="删除路线" style="width:450px;height:200px; padding:10px 20px" closed="true" buttons="#send-del-rail-route-cmd-dlg-buttons">
	<form id="send-del-rail-route-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-del-rail-route-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8607">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-del-rail-route-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>路线：</label><select name="areaId" id="send-del-rail-route-cmd-dlg-frm-areaId" class="easyui-validatebox textbox" required="true">
			<option value="">全部区域</option>
			</select>
		</div>
	</form>
</div>
<div id="send-del-rail-route-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="sendDelRailCmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>


<script  type="text/javascript">
$(document).ready(function() {
	initRailLabelPointSetting("send-set-rail-circle-cmd-dlg-frm-rail",2,5);
	initRailLabelPointSetting("send-set-rail-rectangle-cmd-dlg-frm-rail",3,5);
	initRailLabelPointSetting("send-set-rail-polygon-cmd-dlg-frm-rail",4,5);
	initRailLabelPointSetting("send-set-rail-route-cmd-dlg-frm-rail",5,6);
});

function initRailLabelPointSetting(objId,type,bizType){
	var url = management_api_server_servlet_path+"/common/query/deviceLabelPoint.json?select=id,name&countable=true&pageSize=1000&pageNo=1&orderBy=createTime&desc=true";
	var data = {};
	data["bizType.eq"]=bizType;
	data["type.eq"]=type;
	ajaxAsyncPost(url,data,function(result){
		if (result.code!=0) {
			showErrorMessage(result.message);
			return;
		}
		var rows = result.data.rows;
		$("#"+objId).empty(); 
		for(var i=0;i<rows.length;i++){
			var item = rows[i];
			$("#"+objId).append("<option value='"+item[0]+"'>"+item[1]+"</option>");
		}
	});
}

function sendSetCircleRailCmd(){
	if(!$("#"+current_dialog_id+"-frm").form('validate')){
		return;
	}
	var form = $("#"+current_dialog_id+"-frm").serializeObject();
	var deviceId = form.deviceId;
	var messageId=form.messageId;
	var labelPointId = $("#"+current_dialog_id+"-frm-rail").val();
	var labelPoint = getDeviceLabelPoint(labelPointId);
	var data={};
	form.name = labelPoint.name;
	var setting = labelPoint.setting;
	var area = {};
	area.centerLng = setting.lng;
	area.centerLat = setting.lat;
	area.radius = setting.radius;
	
	var attribute = "";
	for(var i=0;i<16;i++){
		 var bool =false;
		for(var j=0;j<form.attribute.length;j++){
			if(i==form.attribute[j]){
				bool = true;
				break;
			}
		}
		if(bool){
			attribute="1"+attribute;
		}else{
			attribute="0"+attribute;
		}
	}

	area.attribute = attribute;
	area.areaId = getRailAreaId(deviceId,messageId);
	area.limitedSpeed = parseInt(form.limitedSpeed);
	area.durationTime = parseInt(form.durationTime);
	area.startTime = form.startTime;
	area.endTime = form.endTime;
	data.type = 1;
	var areaList = [];
	areaList[0] = area;
	data.areaList = areaList;
	doSendCmd(deviceId,messageId,data);
}

function sendDelRailCmd(){
	var form = $("#"+current_dialog_id+"-frm").serializeObject();
	var deviceId = form.deviceId;
	var messageId=form.messageId;
	var areaIds = [];
	var areaId = form.areaId;
	if(areaId!=""){
		areaIds[0]=areaId;
	}
	var data = {};
	data.areaIds=areaIds;
	doSendCmd(deviceId,messageId,data);
}

function sendSetRectangleRailCmd(){
	if(!$("#"+current_dialog_id+"-frm").form('validate')){
		return;
	}
	var form = $("#"+current_dialog_id+"-frm").serializeObject();
	var deviceId = form.deviceId;
	var messageId=form.messageId;
	var labelPointId = $("#"+current_dialog_id+"-frm-rail").val();
	var labelPoint = getDeviceLabelPoint(labelPointId);
	var data={};
	form.name = labelPoint.name;
	var setting = labelPoint.setting;
	var area = {};
	var path = setting.path.split(";");
	var arr = path[0].split(",");
	area.topLeftLng = parseFloat(arr[0]);
	area.topLeftLat = parseFloat(arr[1]);
	arr = path[3].split(",");
	area.bottomRightLng = parseFloat(arr[0]);
	area.bottomRightLat = parseFloat(arr[1]);
	
	var attribute = "";
	for(var i=0;i<16;i++){
		 var bool =false;
		for(var j=0;j<form.attribute.length;j++){
			if(i==form.attribute[j]){
				bool = true;
				break;
			}
		}
		if(bool){
			attribute="1"+attribute;
		}else{
			attribute="0"+attribute;
		}
	}

	area.attribute = attribute;
	area.areaId = getRailAreaId(deviceId,messageId);
	area.limitedSpeed = parseInt(form.limitedSpeed);
	area.durationTime = parseInt(form.durationTime);
	area.startTime = form.startTime;
	area.endTime = form.endTime;
	data.type = 1;
	var areaList = [];
	areaList[0] = area;
	data.areaList = areaList;
	doSendCmd(deviceId,messageId,data);
}

function sendSetPolygonRailCmd(){
	if(!$("#"+current_dialog_id+"-frm").form('validate')){
		return;
	}
	var form = $("#"+current_dialog_id+"-frm").serializeObject();
	var deviceId = form.deviceId;
	var messageId=form.messageId;
	var labelPointId = $("#"+current_dialog_id+"-frm-rail").val();
	var labelPoint = getDeviceLabelPoint(labelPointId);

	var setting = labelPoint.setting;
	var path = setting.path.split(";");
	var vertexList = [];
	for(var i=0,l=path.length;i<l;i++){
		var arr = path[i].split(",");
		var point = {};
		point.lng = parseFloat(arr[0]);
		point.lat = parseFloat(arr[1]);
		vertexList.push(point);
	}

	var attribute = "";
	for(var i=0;i<16;i++){
		 var bool =false;
		for(var j=0;j<form.attribute.length;j++){
			if(i==form.attribute[j]){
				bool = true;
				break;
			}
		}
		if(bool){
			attribute="1"+attribute;
		}else{
			attribute="0"+attribute;
		}
	}
	var data={};
	data.attribute = attribute;
	data.areaId = getRailAreaId(deviceId,messageId);
	data.limitedSpeed = parseInt(form.limitedSpeed);
	data.durationTime = parseInt(form.durationTime);
	data.startTime = form.startTime;
	data.endTime = form.endTime;
	data.type = 1;
	var areaList = [];
	data.vertexList = vertexList;
	doSendCmd(deviceId,messageId,data);
}

function getDeviceLabelPoint(labelPointId){
	var url=management_api_server_servlet_path+"/common/deviceLabelPoint/"+labelPointId+".json";
	var result = ajaxSyncGet(url,{});
	if (result.code!=0) {
		showErrorMessage(result.message);
		return;
	}
	var labelPoint = result.data;
	var labelPointSetting = JSON.parse(labelPoint.setting);
	labelPoint.setting = labelPointSetting;
	return labelPoint;
}

function getRailAreaId(deviceId,messageId){
	var url = message_api_server_servlet_path+"/common/query/deviceDownMessage.json?countable=false&pageSize=1&pageNo=1&orderBy=createTime&desc=true";
	var data = {};
	data["deviceId.eq"]=deviceId;
	data["messageId.eq"]=messageId;
	var result = ajaxSyncPost(url,data);
	if (result.code!=0) {
		showErrorMessage(result.message);
		return null;
	}
	if(result.data && result.data.length > 0 ){
		var item = result.data[0];
		var messageBody = JSON.parse(item.messageBody);
		var areaList = messageBody.areaList;
		if(areaList){
			var areaId = areaList[areaList.length-1].areaId + 1;
			if(areaId > 65530 ){
				areaId = 1; 
			}
			return areaId;
		}
	}
	return 1;
}
</script><div id="send-8103-0050-cmd-dlg"  class="easyui-dialog" title="告警开关设置" style="width:800px;height:600px; padding:10px 20px" closed="true" buttons="#send-8103-0050-cmd-dlg-buttons">
	<form id="send-8103-0050-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-8103-0050-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8103">
		<input name="paramkey" type="hidden" value="0050">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-8103-0050-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div id="cmd_setting_81030050_div">
		</div>
	</form>
</div>
<div id="send-8103-0050-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="send81030050Cmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>
<script  type="text/javascript">
$(document).ready(function() {
	init81030050();
});

function init81030050(){
	var html="<div class='fitem'>";
	var count=0;
	for(var i=0;i<32;i++){
		if(count>0&&count%2==0){
			html+="</div><div class='fitem'>"
		}
		var alarmName = carAlarmInfoMap.get(i);
		if(alarmName=='未定义'){
			continue;
		}
		count++;
		html+="<label style='width:150px;'>"+alarmName+"：</label>开<input checked='checked' style='width:50px;' type='radio' value='1' name='cmd_setting_81030050_alarm_type_"+i+"'>关<input style='width:50px;' type='radio' value='0' name='cmd_setting_81030050_alarm_type_"+i+"'>";
	}
	html+="</div>";
	$("#cmd_setting_81030050_div").html(html);
}

function send81030050Cmd(){
	var form = $("#"+current_dialog_id+"-frm").serializeObject();
	var flag = "";
	for(var i=0;i<32;i++){
		var val = $("input[name='cmd_setting_81030050_alarm_type_"+i+"']:checked").val();
		if(val=="1"){
			flag+="1";
		}else{
			flag+="0";
		}
	}
	var data={};
	data[form.paramkey]=parseInt(flag,2).toString(16);
	var deviceId = form.deviceId;
	var messageId=form.messageId;
	doSendCmd(deviceId,messageId,{"paramList":data})
}
</script><div id="send-8103-0052-cmd-dlg"  class="easyui-dialog" title="报警拍摄开关设置" style="width:800px;height:600px; padding:10px 20px" closed="true" buttons="#send-8103-0052-cmd-dlg-buttons">
	<form id="send-8103-0052-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-8103-0052-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8103">
		<input name="paramkey" type="hidden" value="0052">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-8103-0052-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div id="cmd_setting_81030052_div">
		</div>
	</form>
</div>
<div id="send-8103-0052-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="send81030052Cmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>
<script  type="text/javascript">
$(document).ready(function() {
	init81030052();
});

function init81030052(){
	var html="<div class='fitem'>";
	var count=0;
	for(var i=0;i<32;i++){
		if(count>0&&count%2==0){
			html+="</div><div class='fitem'>"
		}
		var alarmName = carAlarmInfoMap.get(i);
		if(alarmName=='未定义'){
			continue;
		}
		count++;
		html+="<label style='width:150px;'>"+alarmName+"：</label>开<input checked='checked' style='width:50px;' type='radio' value='1' name='cmd_setting_81030052_alarm_type_"+i+"'>关<input style='width:50px;' type='radio' value='0' name='cmd_setting_81030052_alarm_type_"+i+"'>";
	}
	html+="</div>";
	$("#cmd_setting_81030052_div").html(html);
}

function send81030052Cmd(){
	var form = $("#"+current_dialog_id+"-frm").serializeObject();
	var flag = "";
	for(var i=0;i<32;i++){
		var val = $("input[name='cmd_setting_81030052_alarm_type_"+i+"']:checked").val();
		if(val=="1"){
			flag+="1";
		}else{
			flag+="0";
		}
	}
	var data={};
	data[form.paramkey]=parseInt(flag,2).toString(16);
	var deviceId = form.deviceId;
	var messageId=form.messageId;
	doSendCmd(deviceId,messageId,{"paramList":data})
}
</script><div id="send-8103-0053-cmd-dlg"  class="easyui-dialog" title="报警拍摄存储设置" style="width:800px;height:600px; padding:10px 20px" closed="true" buttons="#send-8103-0053-cmd-dlg-buttons">
	<form id="send-8103-0053-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-8103-0053-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8103">
		<input name="paramkey" type="hidden" value="0053">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-8103-0053-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div id="cmd_setting_81030053_div">
		</div>
	</form>
</div>
<div id="send-8103-0053-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="send81030053Cmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>
<script  type="text/javascript">
$(document).ready(function() {
	init81030053();
});

function init81030053(){
	var html="<div class='fitem'>";
	var count=0;
	for(var i=0;i<32;i++){
		if(count>0&&count%2==0){
			html+="</div><div class='fitem'>"
		}
		var alarmName = carAlarmInfoMap.get(i);
		if(alarmName=='未定义'){
			continue;
		}
		count++;
		html+="<label style='width:150px;'>"+alarmName+"：</label>存储终端<input checked='checked' style='width:50px;' type='radio' value='1' name='cmd_setting_81030053_alarm_type_"+i+"'>实时上传<input style='width:50px;' type='radio' value='0' name='cmd_setting_81030053_alarm_type_"+i+"'>";
	}
	html+="</div>";
	$("#cmd_setting_81030053_div").html(html);
}

function send81030053Cmd(){
	var form = $("#"+current_dialog_id+"-frm").serializeObject();
	var flag = "";
	for(var i=0;i<32;i++){
		var val = $("input[name='cmd_setting_81030053_alarm_type_"+i+"']:checked").val();
		if(val=="1"){
			flag+="1";
		}else{
			flag+="0";
		}
	}
	var data={};
	data[form.paramkey]=parseInt(flag,2).toString(16);
	var deviceId = form.deviceId;
	var messageId=form.messageId;
	doSendCmd(deviceId,messageId,{"paramList":data})
}
</script><div id="send-8103-0054-cmd-dlg"  class="easyui-dialog" title="关键报警设置" style="width:800px;height:600px; padding:10px 20px" closed="true" buttons="#send-8103-0054-cmd-dlg-buttons">
	<form id="send-8103-0054-cmd-dlg-frm" method="post">
		<input name="deviceId" id="send-8103-0054-cmd-dlg-frm-deviceId" type="hidden">
		<input name="messageId" type="hidden" value="8103">
		<input name="paramkey" type="hidden" value="0054">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="send-8103-0054-cmd-dlg-frm-name" class="easyui-validatebox textbox">
		</div>
		<div id="cmd_setting_81030054_div">
		</div>
	</form>
</div>
<div id="send-8103-0054-cmd-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="send81030054Cmd()">发送</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeCmdDialog()">关闭</a>
</div>
<script  type="text/javascript">
$(document).ready(function() {
	init81030054();
});

function init81030054(){
	var html="<div class='fitem'>";
	var count=0;
	for(var i=0;i<32;i++){
		if(count>0&&count%2==0){
			html+="</div><div class='fitem'>"
		}
		var alarmName = carAlarmInfoMap.get(i);
		if(alarmName=='未定义'){
			continue;
		}
		count++;
		html+="<label style='width:150px;'>"+alarmName+"：</label>是<input checked='checked' style='width:50px;' type='radio' value='1' name='cmd_setting_81030054_alarm_type_"+i+"'>否<input style='width:50px;' type='radio' value='0' name='cmd_setting_81030054_alarm_type_"+i+"'>";
	}
	html+="</div>";
	$("#cmd_setting_81030054_div").html(html);
}

function send81030054Cmd(){
	var form = $("#"+current_dialog_id+"-frm").serializeObject();
	var flag = "";
	for(var i=0;i<32;i++){
		var val = $("input[name='cmd_setting_81030054_alarm_type_"+i+"']:checked").val();
		if(val=="1"){
			flag+="1";
		}else{
			flag+="0";
		}
	}
	var data={};
	data[form.paramkey]=parseInt(flag,2).toString(16);
	var deviceId = form.deviceId;
	var messageId=form.messageId;
	doSendCmd(deviceId,messageId,{"paramList":data})
}
</script><script language="javaScript">
function closeCmdDialog(){
	closeDialog(current_dialog_id);
}

function sendTerminalParameterSettingCmd(){
	var form = $("#"+current_dialog_id+"-frm").serializeObject();
	var paramkeys=form.paramkeys;
	var params = paramkeys.split(",");
	var data={};
	var bool=false;
	for(var i in params){
		var param=params[i];
		var val=form[param];
		if(!val||val==""){
			continue;
		}
		var a =param.split("_");
		if(a[0]=="d" || a[0]=="w" ){
			data[a[1]]=parseInt(val).toString(16);
		}else if(a[0]=="s"){
			data[a[1]]=val;
		}
		bool=true;
	}
	if(!bool){
		showErrorMessage("请设置参数值！");
		return;
	}
	var deviceId = form.deviceId;
	var messageId=form.messageId;
	doSendCmd(deviceId,messageId,{"paramList":data})
}


function sendCmd(){
	if(!$("#"+current_dialog_id+"-frm").form('validate')){
		return;
	}
	var data = $("#"+current_dialog_id+"-frm").serializeObject();
	var deviceId = data.deviceId;
	var messageId=data.messageId;
	doSendCmd(deviceId,messageId,data);
}

function doSendCmd(deviceId,messageId,data){
	if(!isOnline(deviceId)){
		showErrorMessage("终端不在线，不能发送指令！");
		return;
	}
	var url=message_api_server_servlet_path+"/deviceDownMessage/"+deviceId+"/"+messageId+".json";
	var desc = $("#"+current_dialog_id).panel('options').title;
	if(desc){
		data.desc=desc;
	}
	ajaxAsyncPost(url,data,function(result){
		if (result.code!=0) {
			showErrorMessage(result.message);
		}  else {
			closeCmdDialog();
			var result=result.data;
			setCmdInfo(result);
			showMessage("指令已下发，等待网关处理中");
		}
	});
}


function sendTestCmd(){
	var data = $("#"+current_dialog_id+"-frm").serializeObject();
	var deviceId = data.deviceId;
	if(!isOnline(deviceId)){
		showErrorMessage("终端不在线，不能发送指令！");
		return;
	}
	var url=message_api_server_servlet_path+"/deviceDownMessage/"+deviceId+"/"+data.messageId+".json";
	data=JSON.parse($("#send-test-cmd-dlg-frm-messageBody").val());
	ajaxAsyncPost(url,data,function(result){
		if (result.code!=0) {
			showErrorMessage(result.message);
		}  else {
			closeCmdDialog();
			showMessage("指令已下发，网关处理中，消息流水号："+result.data.messageSeq);
		}
	});
}

</script><div id="cmd-menu" class="easyui-menu" style="width:130px;">
		
		<div onclick="openDialog('send-phone-tapping-cmd-dlg')">远程监听</div>
		<div onclick="openDialog('send-phone-call-cmd-dlg')">远程通话</div>
		<div onclick="openDialog('send-car-location-query-cmd-dlg')" >位置查询</div>
		<div onclick="openDialog('send-location-temporary-query-cmd-dlg')">临时跟踪</div>
		<div onclick="openDialog('send-text-info-cmd-dlg')">文本信息</div>
		<div>
			<span>终端控制</span>
			<div style="width:150px;">
				<div onclick="openDialog('send-car-lock-cmd-dlg')">远程锁车</div>
				<div onclick="openDialog('send-car-unlock-cmd-dlg')">远程解锁</div>
				<div class="menu-sep"></div>
				<div onclick="openDialog('send-terminal-control-shutdown-cmd-dlg')">关机</div>
				<div onclick="openDialog('send-terminal-control-reset-cmd-dlg')">复位终端</div>
				<div onclick="openDialog('send-terminal-control-reset-factory-setting-cmd-dlg')">恢复出厂设置</div>
				<div onclick="openDialog('send-terminal-control-turn-off-data-communication-cmd-dlg')">关闭数据通讯</div>
				<div onclick="openDialog('send-terminal-control-turn-off-wireless-communication-cmd-dlg')">关闭无线通讯</div>
				<!-- <div onclick="openDialog('')">连接指定服务器</div>
				<div onclick="openDialog('')">切换原缺省服务器</div>
				<div onclick="openDialog('')">无线升级</div>
				<div name="div-cmd-menu-jtt-808-2013" class="menu-sep"></div>
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">终端属性</div> -->
				
			</div>
		</div>
		<div>
			<span>信息服务</span>
			<div style="width:150px;">
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('send-text-info-2013-cmd-dlg')">文本信息</div>
				<div name="div-cmd-menu-jtt-808-2011" onclick="openDialog('send-text-info-2011-cmd-dlg')">文本信息</div>
				<div onclick="openDialog('send-text-info-service-cmd-dlg')">信息服务</div>
				<!--  div onclick="openDialog('')">提问</div>
				<div onclick="openDialog('')">事件设置</div>
				<div onclick="openDialog('')">点播菜单设置</div>-->
			</div>
		</div>
		<div>
			<span>终端参数</span>
			<div style="width:160px;">
				<div onclick="openDialog('send-terminal-parameter-query-cmd-dlg')">参数查询</div>
<!-- 				<div name="div-cmd-menu-jtt-808-2013"  onclick="openDialog('')">查询指定参数</div> -->
				<div class="menu-sep"></div>
				<div onclick="openDialog('send-terminal-parameter-heartbeat-cmd-dlg')">心跳间隔</div>
				<div onclick="openDialog('send-terminal-parameter-report-strategy-cmd-dlg')">汇报策略</div>
				<div onclick="openDialog('send-8103-0050-cmd-dlg')">报警开关</div>
				<div onclick="openDialog('send-8103-0052-cmd-dlg')">报警拍摄开关</div>
				<div onclick="openDialog('send-8103-0053-cmd-dlg')">报警拍摄存储设置</div>
				<div onclick="openDialog('send-8103-0054-cmd-dlg')">关键报警设置</div>
				<!--  
				<div onclick="openDialog('')">通讯协议</div>
				<div onclick="openDialog('')">主服务器</div>
				<div onclick="openDialog('')">备用服务器</div>
				<div onclick="openDialog('')">服务器端口</div>
				<div onclick="openDialog('')">拐点补传角度</div>
				<div onclick="openDialog('')">电话号码</div>
				<div onclick="openDialog('')">通话策略</div>
				<div onclick="openDialog('')">SMS</div>
				<div onclick="openDialog('')">报警开关</div>
				<div onclick="openDialog('')">报警器拍照</div>
				<div onclick="openDialog('')">超速</div>
				<div onclick="openDialog('')">疲劳驾驶</div>
				<div onclick="openDialog('')">停车时间</div>
				<div onclick="openDialog('')">图像</div>
				<div onclick="openDialog('')">车辆信息</div>
				
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">IC卡认证</div>
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">电子围栏</div>
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">预警差值</div>
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">碰撞报警</div>
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">侧翻报警</div>
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">GNSS</div>
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">CAN总线</div>
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">CAN总线ID单独采集</div>
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">其他CAN总线ID单独采集</div>
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">定时拍照控制位</div>
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">定距拍照控制位</div>
				-->
			</div>
		</div>
		<div>
			<span>拍摄控制</span>
			<div style="width:100px;">
				<div onclick="openDialog('send-take-one-picture-cmd-dlg')">单张拍照</div>
				<div onclick="openDialog('send-take-many-picture-cmd-dlg')">定时拍摄</div>
				<div onclick="openDialog('send-stop-take-picture-cmd-dlg')">停止拍摄</div>
				<div class="menu-sep"></div>
				<div onclick="openDialog('send-take-video-cmd-dlg')">录像采集</div>
				<div onclick="openDialog('send-stop-take-picture-cmd-dlg')">停止录像</div>
				<div class="menu-sep"></div>
				<div onclick="openDialog('send-start-record-cmd-dlg')">录音采集</div>
				<div onclick="openDialog('send-stop-record-cmd-dlg')">停止录音</div>
				<div class="menu-sep"></div>
				<div onclick="openDialog('send-media-data-query-cmd-dlg')">数据检索</div>
				<div onclick="openDialog('send-media-data-upload-cmd-dlg')">数据上传</div>
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('send-one-media-data-upload-cmd-dlg')">单条检索</div>
			</div>
		</div>
		<div>
			<span>电子围栏</span>
			<div style="width:100px;">
				<div onclick="openDialog('send-set-rail-circle-cmd-dlg')">设置圆形区域</div>
				<div onclick="openDialog('send-del-rail-circle-cmd-dlg')">删除圆形区域</div>
				<div onclick="openDialog('send-set-rail-rectangle-cmd-dlg')">设置矩形区域</div>
				<div onclick="openDialog('send-del-rail-rectangle-cmd-dlg')">删除矩形区域</div>
				<div onclick="openDialog('send-set-rail-polygon-cmd-dlg')">设置多边形区域</div>
				<div onclick="openDialog('send-del-rail-polygon-cmd-dlg')">删除多边形区域</div>
				<!-- <div onclick="openDialog('send-set-rail-route-cmd-dlg')">设置线路</div> -->
				<div onclick="openDialog('send-del-rail-route-cmd-dlg')">删除线路</div>
			</div>
		</div>
		<!-- 
		<div>
			<span>记录仪参数</span>
			<div style="width:100px;">
				<div name="div-cmd-menu-jtt-808-2013"  onclick="openDialog('')">车辆信息</div>
				<div name="div-cmd-menu-jtt-808-2013"  onclick="openDialog('')">安装时间</div>
				<div name="div-cmd-menu-jtt-808-2013"  onclick="openDialog('')">状态量</div>
				<div name="div-cmd-menu-jtt-808-2013"  onclick="openDialog('')">记录仪时间</div>
				<div name="div-cmd-menu-jtt-808-2013"  onclick="openDialog('')">脉冲系数</div>
				<div name="div-cmd-menu-jtt-808-2013"  onclick="openDialog('')">初始里程</div>
				
				<div name="div-cmd-menu-jtt-808-2011" onclick="openDialog('')">车辆信息</div>
				<div name="div-cmd-menu-jtt-808-2011" onclick="openDialog('')">驾驶员信息</div>
				<div name="div-cmd-menu-jtt-808-2011" onclick="openDialog('')">记录仪时钟</div>
				<div name="div-cmd-menu-jtt-808-2011" onclick="openDialog('')">车辆特征系数</div>
			</div>
		</div>-->
		
		<div>
			<span>记录仪数据</span>
			<div style="width:180px;"><!--  
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">执行标准版本</div>
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">当前驾驶人信息</div>
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">实时时间</div>
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">累计行驶里程</div>
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">车辆信息</div>
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">脉冲系数</div>
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">状态信号配置信息</div>
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">唯一性编号</div>
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">行驶速度记录</div>
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">位置信息记录</div>
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">事故疑点记录</div>
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">超时驾驶记录</div>
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">驾驶人身份记录</div>
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">外部供电记录</div>
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">参数修改记录</div>
				<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">速度状态日志</div>-->
				
				<div name="div-cmd-menu-jtt-808-2011" onclick="openDialog('send-dvr2003-data-driver-info-cmd-dlg')">驾驶员信息</div>
				<div name="div-cmd-menu-jtt-808-2011" onclick="openDialog('send-dvr2003-data-timestamp-cmd-dlg')">记录仪时钟</div>
				<div name="div-cmd-menu-jtt-808-2011" onclick="openDialog('send-dvr2003-data-car-info-cmd-dlg')">车辆信息</div>
				<div name="div-cmd-menu-jtt-808-2011" onclick="openDialog('send-dvr2003-data-car-coefficient-cmd-dlg')">车辆特征系数</div>
				<div name="div-cmd-menu-jtt-808-2011" onclick="openDialog('send-dvr2003-data-360h-mileage-cmd-dlg')">最近360h内行驶里程</div>
				<div name="div-cmd-menu-jtt-808-2011" onclick="openDialog('send-dvr2003-data-48h-mileage-cmd-dlg')">最近两个日历天内行驶里程</div>
				<div name="div-cmd-menu-jtt-808-2011" onclick="openDialog('send-dvr2003-data-360h-speed-cmd-dlg')">最近360h内行驶速度</div>
				<div name="div-cmd-menu-jtt-808-2011" onclick="openDialog('send-dvr2003-data-48h-speed-cmd-dlg')">最近两个日历天内行驶速度</div>
				<div name="div-cmd-menu-jtt-808-2011" onclick="openDialog('send-dvr2003-data-driver-accident-place-cmd-dlg')">最近10个事故疑点</div>
				<div name="div-cmd-menu-jtt-808-2011" onclick="openDialog('send-dvr2003-data-drowsy-driving-cmd-dlg')">疲劳驾驶</div>
			</div>
		</div>
		
		<!-- 
		<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">驾驶员信息</div>
		<div name="div-cmd-menu-jtt-808-2013" onclick="openDialog('')">确认告警</div>
		<div data-options="iconCls:'icon-save'">Save</div> -->
<!-- 		<div data-options="iconCls:'icon-print',disabled:true">Print</div> -->
<!-- 		<div class="menu-sep"></div> -->
<!-- 		<div>Exit</div> -->
	</div>
<script language="javaScript">
function showCmdMenu(x,y){
	if(!current_selected_device){
		showMessage("请选择要操作的设备！");
		return;
	}
	var protocolVersion = current_selected_device.protocolVersion;
	//隐藏其他版本的指令
	//选择所有的name属性以'div-cmd-menu-'开头的div元素 
	$("div[name^='div-cmd-menu-']").each(function(){
        var name=$(this).attr("name");
        if(name.indexOf(protocolVersion)!=-1){
        	$(this).show();
        }else{
        	$(this).hide();
        }
	});

	$("#cmd-menu").menu("show", {
		left: x,
		top: y
	});
}
</script><div id="label-point-setting-menu" class="easyui-menu" style="width:100px;">
		<div onclick="drawLabelPoint(1)">位置点</div>
		<div onclick="drawLabelPoint(2)">圆形</div>
		<div onclick="drawLabelPoint(3)">矩形</div>
		<div onclick="drawLabelPoint(4)">多边形</div>
		<div onclick="drawLabelPoint(5)">路线</div>
</div>

<div id="label-point-setting-gps-history-query-dlg" class="easyui-dialog" title="历史轨迹查询" style="width: 450px; height: 180px; padding: 10px 20px" closed="true" buttons="#label-point-setting-gps-history-query-dlg-buttons">
	<form id="label-point-setting-gps-history-query-dlg-frm" method="post">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="label-point-setting-gps-history-query-dlg-frm-name" maxlength="16"  class="easyui-validatebox textbox" style="width:230px;">
		</div>
		<div class="fitem">
			<label>轨迹时间：</label><input class="easyui-datebox" style="width:95px;" name="date" id="label-point-setting-gps-history-query-dlg-frm-date" editable="false" data-options="required:true">
			<input class="easyui-timespinner" style="width:80px;" name="startTime" id="label-point-setting-gps-history-query-dlg-frm-startTime"  data-options="required:true,showSeconds:true">-
			<input class="easyui-timespinner" style="width:80px;" name="endTime" id="label-point-setting-gps-history-query-dlg-frm-endTime"   data-options="required:true,showSeconds:true">
		</div>
	</form>
</div>
<div id="label-point-setting-gps-history-query-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="collectRoute()">查询</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeDialog('label-point-setting-gps-history-query-dlg')">关闭</a>
</div>

<div id="label-point-setting-dlg" class="easyui-dialog" title="标注设置" style="width: 450px; height: 330px; padding: 10px 20px" closed="true" buttons="#label-point-setting-dlg-buttons">
	<form id="label-point-setting-dlg-frm" method="post">
		<input name="type" id="label-point-setting-dlg-frm-type"  type="hidden">
		<div class="fitem">
			<label>标注名称：</label><input name="name" maxlength="16" required="true" class="easyui-validatebox textbox">
		</div>
		<div class="fitem">
			<label>业务类型：</label><select name="bizType" id="label-point-setting-dlg-frm-bizType" class="easyui-validatebox textbox" required="true">
					  <option  value ="1">区域查车</option>
					  <option  value ="2">电子围栏</option>
			</select>
		</div>
		<div class="fitem">
			<label>标注备注：</label><textarea  name="text"  style="height:150px;width:280px;" maxlength="250"  class="easyui-validatebox textbox"/></textarea>
		</div>
	</form>
</div>
<div id="label-point-setting-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveLabelPointSetting()">保存</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeDialog('label-point-setting-dlg')">关闭</a>
</div>

<script  type="text/javascript">
var current_label_point_setting ={};
var is_label_point_type_point_set=false;

var typeMap = new JsMap();
var bizTypeMap = new JsMap();
bizTypeMap.put(1,"停车场");
bizTypeMap.put(2,"途径点");
bizTypeMap.put(3,"站点");
typeMap.put(1,bizTypeMap);

bizTypeMap = new JsMap();
bizTypeMap.put(4,"区域查车");
bizTypeMap.put(5,"电子围栏");
typeMap.put(2,bizTypeMap);
typeMap.put(3,bizTypeMap);
typeMap.put(4,bizTypeMap);

bizTypeMap = new JsMap();
bizTypeMap.put(6,"行驶路线");
typeMap.put(5,bizTypeMap);

function showLabelPointMenu(x,y){
	$("#label-point-setting-menu").menu("show", {
		left: x,
		top: y
	});
}

function drawLabelPoint(type){
	mapUtil.closeDraw();
	mapUtil.openDraw();
	var message = "";
	if(type==1){
		is_label_point_type_point_set = true;
		message = "画点";
	}else if(type==2){
		message = "画圆形";
		mapUtil.drawCircle(drawLabelPointCircleCompletedHandler);
	}else if(type==3){
		message = "画矩形";
		mapUtil.drawRectangle(drawLabelPointPolygonCompletedHandler);
	}else if(type==4){
		message = "画多边形";
		mapUtil.drawPolygon(drawLabelPointPolygonCompletedHandler);
	}else if(type==5){
		message = "采集路线";
		openDialog("label-point-setting-gps-history-query-dlg");
	}
	$("#label-point-setting-dlg-frm-type").val(type);
	var bizTypeMap = typeMap.get(type);
	$("#label-point-setting-dlg-frm-bizType").empty(); 
	var keys = bizTypeMap.getKeys();
	for(var i=0;i<keys.length;i++){
		var key = keys[i];
		$("#label-point-setting-dlg-frm-bizType").append("<option value='"+key+"'>"+bizTypeMap.get(key)+"</option>");
	}
	showMessage("请在地图上"+message+"！");
}

function drawLabelPointPointCompletedHandler(){
	 var setting = {};
	 setting.lng = map_onclick_event_lnglat.getLng();
	 setting.lat = map_onclick_event_lnglat.getLat();
     if(is_label_point_type_point_set){
         var marker = new AMap.Marker({
             position: [setting.lng,setting.lat]
         });
         marker.setMap(mapUtil.getMap());
         current_label_point_setting = setting;
         is_label_point_type_point_set = false;
         $("#label-point-setting-dlg").dialog("open");
     }
}

function drawLabelPointCircleCompletedHandler(e, circle){
	circle=e.obj;
	current_circle=circle;
	var point=circle.getCenter();
	//国测局坐标转wgs84坐标
    var wgs84 = LngLatConverter.gcj02towgs84(point.getLng(), point.getLat());
	var setting = {};
	setting.radius = parseInt(circle.getRadius());
	setting.lat = wgs84[1];
	setting.lng = wgs84[0];
	current_label_point_setting = setting;
	mapUtil.closeDraw();
	$("#label-point-setting-dlg").dialog("open");
}

function drawLabelPointPolygonCompletedHandler(e, polygon){
	polygon=e.obj;
	current_polygon=polygon;
	var path=polygon.getPath();
	var points = "";
	//国测局坐标转wgs84坐标
	for(var i=0;i<path.length;i++){
		var point = path[i];
		var wgs84 = LngLatConverter.gcj02towgs84(point.getLng(), point.getLat());
		points+=";"+wgs84[0]+","+wgs84[1];
	}
	var setting = {};
	setting.path = points.substr(1);
	current_label_point_setting = setting;
	mapUtil.closeDraw();
	$("#label-point-setting-dlg").dialog("open");
}

function collectRoute(){
	if(!$("#label-point-setting-gps-history-query-dlg-frm").form('validate')) return;
	var form = $("#label-point-setting-gps-history-query-dlg-frm").serializeObject();
	var data = {};
	data["recordDate"]=form.date;
	var rangeCondition ={};
	rangeCondition["fieldName"]="gpsTime"; 
	rangeCondition["from"]=new Date((form.date+" "+form.startTime).replace(/-/g,"/")).getTime();
	rangeCondition["includeLower"]=true;
	rangeCondition["includeUpper"]=true; 
	rangeCondition["to"]=new Date((form.date+" "+form.endTime).replace(/-/g,"/")).getTime();
	var rangeConditions= new Array();
	rangeConditions[0]=rangeCondition;
	data["rangeConditions"]=rangeConditions;
	var url=lbs_api_server_servlet_path+"/gps/"+current_selected_device.id+"/simple.json";
	ajaxAsyncPost(url,data,collectRouteResultHandler);
}

function collectRouteResultHandler(result){
	if (result.code!=0) {
		showErrorMessage(result.message);
		return
	}
	var data = result.data;
	if(!data || !data.points || data.points.length <= 0){
		showMessage("您所查询的时间段内无该设备的定位数据");
		return;
	}
	var gpsList = data.points;
	//地图上画轨迹
	var map=mapUtil.getMap();
	var points=new Array();
	var index=0;
	var gpsStr = "";
	for(var i=0,l=gpsList.length;i<l;i++){
		var item=gpsList[i];
		var gcj02 = LngLatConverter.wgs84togcj02(item.lng,item.lat);
		var point=mapUtil.getPoint(gcj02[0],gcj02[1]);
		points[index++]=point;
		gpsStr+=";"+item.lng+","+item.lat;
	}

	if(points.length>0){
		map.panTo(points[0]);
		mapUtil.drawPolyline(points,"red");
	}
	
	var setting = {};
	setting.route = gpsStr.substr(1);
	setting.width = 100;//路宽
	setting.maxDistance = data.maxDistance;//路两点间的最大距离
	current_label_point_setting = setting;
	closeDialog("label-point-setting-gps-history-query-dlg");
	$("#label-point-setting-dlg").dialog("open");
}

function saveLabelPointSetting(){
	var data = $("#label-point-setting-dlg-frm").serializeObject();
	if(data.name==""){
		showMessage("请正确设置标注名称");
		return;
	}
	data.setting=JSON.stringify(current_label_point_setting);
	var url=management_api_server_servlet_path+"/common/deviceLabelPoint.json";
	ajaxAsyncPost(url,data,function(result){
		if (result.code!=0) {
			showErrorMessage(result.message);
		}  else {
			closeDialog("label-point-setting-dlg");
			showMessage("设置成功");
		}
	});
}
</script><div id="gps-history-query-dlg" class="easyui-dialog" title="历史轨迹查询" style="width: 400px; height: 180px; padding: 10px 20px" closed="true" buttons="#gps-history-query-dlg-buttons">
	<form id="gps-history-query-dlg-frm" method="post">
		<div class="fitem">
			<label>设备名称：</label><input name="name" id="gps-history-query-dlg-frm-name" maxlength="16"  class="easyui-validatebox textbox" style="width:230px;">
		</div>
		<div class="fitem">
			<label>轨迹时间：</label><input class="easyui-datebox" style="width:95px;" name="startTime" id="gps-history-query-dlg-frm-startTime" editable="false" data-options="required:true">
			<select name="hour" id="gps-history-query-dlg-frm-hour" class="easyui-validatebox textbox" style="width:135px;">
			</select>
		</div>
	</form>
</div>
<div id="gps-history-query-dlg-buttons">
	<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="doHistoryGpsQuery(1)">查询</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeDialog('gps-history-query-dlg')">关闭</a>
</div>

<script  type="text/javascript">
var gps_current_page_no=1;

function setGpsQueryHourOption(){
	var interval = 6;
	for(var i=0;i<24;){
		var start=i;
		i=i+interval;
		var end=(i-1);
		if(start<10){
			start="0"+start;
		}
		if(end<10){
			end="0"+end;
		}
		var text=start+":00:00-"+end+":59:59";
		$("#gps-history-query-dlg-frm-hour").append("<option value='"+text+"'>"+text+"</option>");
	}
	var now = new Date();
	$("#gps-history-query-dlg-frm-hour").get(0).selectedIndex= Math.floor(now.getHours()/interval);
	$('#gps-history-query-dlg-frm-startTime').datebox('setValue', now.format("yyyy-MM-dd"));
}

function doHistoryGpsQuery(pageNo){
	var form = $("#gps-history-query-dlg-frm").serializeObject();
	var startTime=form.startTime;
	var time=form.hour.split("-");
	var endTime = startTime+" "+time[1];
	var startTime = startTime+" "+time[0];
	var data ={};
	data["recordDate"]=form.startTime;
	var conditions = {};
	conditions["deviceId.eq"]=current_selected_device.id;
	data["conditions"]=conditions;
	
	var rangeCondition ={};
	rangeCondition["fieldName"]="gpsTime"; 
	rangeCondition["from"]=new Date(startTime.replace(/-/g,"/")).getTime();
	rangeCondition["includeLower"]=true;
	rangeCondition["includeUpper"]=true; 
	rangeCondition["to"]=new Date(endTime.replace(/-/g,"/")).getTime();
	var rangeConditions= new Array();
	rangeConditions[0]=rangeCondition;
	data["rangeConditions"]=rangeConditions;
	
	var url=lbs_api_server_servlet_path+"/common/query/gps.json?select=lng,lat&orderBy=gpsTime&pageSize=500&pageNo="+pageNo;
	ajaxAsyncPost(url,data,doHistoryGpsQueryResultHandler);
}

function doHistoryGpsQueryResultHandler(result){
	if(!result || !result.data || result.data.length<=0){
		showMessage("您所查询的时间段内无该设备的定位数据");
		gps_current_page_no=1;
		return;
	}
	
	closeDialog("gps-history-query-dlg");
	result = result.data;
	//drawPolyline(result);
	
	if(result.length>=500){
		setPathData(result,false);
		doHistoryGpsQuery(gps_current_page_no++);
	}else{
		gps_current_page_no=1;
		setPathData(result,true);
	}
}

function drawPolyline(gpsList){
	//地图上画轨迹
	var map=mapUtil.getMap();
	var points=new Array();
	var index=0;
	for(var i=0;i<gpsList.length;i++){
		var item=gpsList[i];
		var gcj02 = LngLatConverter.wgs84togcj02(item.lng,item.lat);
		var point=mapUtil.getPoint(gcj02[0],gcj02[1]);
		if(points.length>0 && mapUtil.getDistance(points[points.length-1],point)>2*1000){
			map.panTo(points[0]);
			mapUtil.drawPolyline(points,"red");
			points=new Array();
			index=0;
		}
		points[index++]=point;
	}

	if(points.length>0){
		map.panTo(points[0]);
		mapUtil.drawPolyline(points,"red");
	}
}

var pathData = [];
function setPathData(gpsList,start){
	var points=new Array();
	var index=0;
	for(var i=0;i<gpsList.length;i++){
		var item=gpsList[i];
		var gcj02 = LngLatConverter.wgs84togcj02(item.lng,item.lat);
		var point=mapUtil.getPoint(gcj02[0],gcj02[1]);
		if(points.length>0 && mapUtil.getDistance(points[points.length-1],point)>2*1000){
			pathData.push({path: points});
			points=new Array();
			index=0;
		}
		points[index++]=point;
	}

	if(points.length>0){
		pathData.push({path: points});
	}
	if(start){
		startPathSimplifier(pathData);
		pathData=[];
	}
}

var pathSimplifierIns=null;
function startPathSimplifier(pathData){
	AMapUI.load(['ui/misc/PathSimplifier', 'lib/$'], function(PathSimplifier, $) {
        if (!PathSimplifier.supportCanvas) {
        	var map=mapUtil.getMap();
        	var points;
            for(var i=0,l=pathData.length;i<l;i++){
            	var item = pathData[i];
            	points = item.path;
        		mapUtil.drawPolyline(points,"red");
            }
			if(points){
	        	map.panTo(points[0]);
			}
            return;
        }
        if(pathSimplifierIns){
            pathSimplifierIns.clearPathNavigators();
    		//pathSimplifierIns.setData(null);
        }
        pathSimplifierIns = new PathSimplifier({
            zIndex: 100,
            //autoSetFitView:false,
            map: mapUtil.getMap(), //所属的地图实例
            getPath: function(pathData, pathIndex) {
                return pathData.path;
            },
            getHoverTitle: function(pathData, pathIndex, pointIndex) {
                return null;
            },
            renderOptions: {
                pathLineStyle: {
                    dirArrowStyle: true
                },
                getPathStyle: function(pathItem, zoom) {
                    var color = '#eb1238',lineWidth = 5;
                    return {
                        pathLineStyle: {
                            strokeStyle: color,
                            lineWidth: lineWidth
                        },
                        pathLineSelectedStyle: {
                            lineWidth: lineWidth + 2
                        },
                        pathNavigatorStyle: {
                            fillStyle: color
                        }
                    };
                }
            }
        });

        window.pathSimplifierIns = pathSimplifierIns;

        //设置数据
        pathSimplifierIns.setData(pathData);

        //对第一条线路（即索引 0）创建一个巡航器
//         var navg = pathSimplifierIns.createPathNavigator(0, {
//             loop: false, //循环播放
//             speed:5000,//巡航速度，单位千米/小时
//             pathNavigatorStyle: {
//                     width: 16,
//                     height: 32,
//                     content: PathSimplifier.Render.Canvas.getImageContent('./images/car.png', onload, onerror),
//                     strokeStyle: null,
//                     fillStyle: null
//             }
//         });

//         navg.start();
    });
}
</script><div id="search-device-menu" class="easyui-menu" style="width:100px;">
		<div onclick="searchDeviceByRail()">圆形区域</div>
		<div onclick="searchDeviceByRectangle()">矩形区域</div>
		<div onclick="searchDeviceByPolygon()">多边形区域</div>
	</div>
</body>
</html>
<script type="text/javascript">

var mapIndexPage=true;
var map_onclick_event_lnglat;
var mapUtil;
var deviceDownMessageMap = new JsMap();
$(document).ready(function() {
	$("#map").height($(document.body).height()-180);
	mapUtil=new MapUtil();
	mapUtil.loadJScript("gd");
	var gpsInterval = setInterval(function () {
		if(current_selected_device) {
			getLastGps(current_selected_device.id);
		}
	}, 10*1000);
	setTimeout("startDwr()",10*1000);
	setGpsQueryHourOption();
	$("#gps-history-query-dlg-frm-startTime").val(new Date().format('yyyy-MM-dd'));

	$("#device-info-datagrid").datagrid({
	    onClickRow:function(rowIndex, rowData){
	    	
	    }
	});
	
	setInterval(function(){
		startQueryJtt808DownMessageState();
	},10*1000);
	
	loadDistrict("8888","province");
});

function showSearchDeviceMenu(x,y){
	$("#search-device-menu").menu("show", {
		left: x,
		top: y
	});
}

function mapOnClickEvent(e){
	map_onclick_event_lnglat = e.lnglat;
	drawLabelPointPointCompletedHandler();
}

var current_jtt808_message_pageno=0;
function startQueryJtt808DownMessageState(){
	var keys=deviceDownMessageMap.getKeys();
	if(keys && keys.length>0){
		var ids="";
		var pageSize=10;
		current_jtt808_message_pageno++;
		var startIndex=(current_jtt808_message_pageno-1)*pageSize;
		if(startIndex>=keys.length){
			current_jtt808_message_pageno=0;
		}
		for(var i=startIndex;(i<keys.length && i< (startIndex+pageSize));i++){
			ids+=","+keys[i];
		}
		if(ids!=""){
			getJtt808DownMessageState(ids.substr(1));
		}
	}
}

function getJtt808DownMessageState(id){
		var url=message_api_server_servlet_path+"/deviceDownMessage/"+id+"/state";
		var data={}
		ajaxAsyncGet(url,data,function(result){
			result=result.data;
			if( !(result && result.length >0)){
				return;
			}
			var rows = $('#device-cmd-datagrid').datagrid('getRows');
			for(var i=0;i<rows.length;i++){
				var row=rows[i];
				for(var j=0;j<result.length;j++){
					var item=result[j];
					var state = getMessageState(item.state);
					if(row.id==item.id && state != row.state){
						row.state=state;
						$('#device-cmd-datagrid').datagrid('updateRow',{
							index: i,
							row: row
						});
						deviceDownMessageMap.remove(item.id);
						break;
					}
				}
			}
			startQueryJtt808DownMessageState();
		});
}

function getMessageState(state){
	 if(state==4){
		 return "网关处理中";
	 }else if(state==0){
		 return "下发成功";
	 }else if(state==1){
		 return "终端不在线";
	 }else if(state==2){
		 return "消息有误";
	 }else if(state==3){
		 return "消息不支持";
	 }else if(state==-1){
		 return "未知错误";
	 }else if(state==5){
		 return "终端已应答";
	 }
}
function resetTabs(){
	var text = $("#tab-tools-1").text();
	if(text.indexOf("展开")!=-1){
		$("#tab-tools-1").text("折叠");
		$("#map").height($(document.body).height()-180);
	}else{
		$("#map").height($(document.body).height()-30);
		$("#tab-tools-1").text("展开");
	}
}

function setCmdInfo(cmdInfo){
	var data={};
	data.id=cmdInfo.id;
	data.deviceName=current_selected_device.name;
	data.simCode=current_selected_device.simCode;
	data.messageDesc=deviceMessageInfoMap.get(cmdInfo.messageId);
	data.messageId=cmdInfo.messageId;
	data.messageSeq=cmdInfo.messageSeq;
	data.createTime=new Date(cmdInfo.createTime).format();
	data.state="网关处理中";
	var rows = $('#device-cmd-datagrid').datagrid('getRows');
	if(rows.length>49){
		deviceDownMessageMap.remove(rows[rows.length-1].id);
		('#device-cmd-datagrid').datagrid('deleteRow',rows.length-1);
	}
	
	$('#device-cmd-datagrid').datagrid('insertRow',{  
	     index : 0,  
	     row : data
	});

	deviceDownMessageMap.put(data.id,data.messageSeq);
}

function setDataLimitAlarmInfo(alarmInfo){
	var data={};
	data.deviceId=alarmInfo.deviceId;
	data.deviceName=alarmInfo.deviceName;
	data.simCode=alarmInfo.simCode;
	data.alarmTime=new Date(alarmInfo.alarmTime).format();
	data.alarmInfo=(alarmInfo.type==1?"每分钟上传数据流量超额":"每分钟上行消息条数超额");
	var rows = $('#device-alarm-datagrid').datagrid('getRows');
	if(rows.length>49){
		('#device-alarm-datagrid').datagrid('deleteRow',rows.length-1);
	}
	
	$('#device-alarm-datagrid').datagrid('insertRow',{  
	     index : 0,  
	     row : data
	});
	//提示告警
	showAlarmTipMessage(data.deviceName,data.alarmInfo);
}

function setDeviceAlarmInfo(alarmInfo){
	var data={};
	data.deviceId=alarmInfo.deviceId;
	data.deviceName=alarmInfo.deviceName;
	data.simCode=alarmInfo.simCode;
	data.alarmTime=new Date(alarmInfo.gpsTime).format();
	var alarmFlag=alarmInfo.alarmFlag;
	var alarmStr="";
	if(alarmInfo.extAlarm){
		var extAlarm = alarmInfo.extAlarm;
		for(var k in extAlarm){
			alarmStr+=","+carAlarmInfoMap.get(31+parseInt(k));
		}
	}
	for(var i=0;i<alarmFlag.length;i++){
		var s="";
		if(alarmFlag.charAt(i)==1){
			s=carAlarmInfoMap.get(i);
		}
		if(s && s!="未定义"){
			alarmStr+=","+s;
		}
	}
	
	if(alarmStr!=""){
		data.alarmInfo=alarmStr.substr(1);
	}
	
	var statusFlag=alarmInfo.statusFlag;
	var statusStr="";
	for(var i=0;i<statusFlag.length;i++){
		var s="";
		if(statusFlag.charAt(i)==0){
			s=carStatusOffInfoMap.get(i);
		}else{
			s=carStatusOnInfoMap.get(i);
		}
		if(s && s!="未定义"){
			statusStr+=","+s;
		}
	}
	if(statusStr!=""){
		data.statusFlag=statusStr.substr(1);
	}
	
	var rows = $('#device-alarm-datagrid').datagrid('getRows');
	if(rows.length>49){
		('#device-alarm-datagrid').datagrid('deleteRow',rows.length-1);
	}
	
	$('#device-alarm-datagrid').datagrid('insertRow',{  
	     index : 0,  
	     row : data
	});
	//提示告警
	showAlarmTipMessage(data.deviceName,data.alarmInfo);
}

function setDeviceInfo(deviceInfo,gpsInfo){
	var data={};
	data.deviceId=deviceInfo.id;
	data.name=deviceInfo.name;
	data.simCode=deviceInfo.simCode;
	data.state=(deviceInfo.state==2?"离线":"在线");
	data.gpsTime=new Date(gpsInfo.gpsTime).format();
	data.speed=gpsInfo.speed;
	data.mileage=gpsInfo.mileage;
	data.oilmass=gpsInfo.oilmass;
	data.lng=gpsInfo.lng;
	data.lat=gpsInfo.lat;
	data.altitude=gpsInfo.altitude;
	var statusFlag=gpsInfo.statusFlag;
	var statusStr="";
	for(var i=0;i<statusFlag.length;i++){
		var s="";
		if(statusFlag.charAt(i)==0){
			s=carStatusOffInfoMap.get(i);
		}else{
			s=carStatusOnInfoMap.get(i);
		}
		if(s && s!="未定义"){
			statusStr+=","+s;
		}
	}
	if(statusStr!=""){
		data.statusFlag=statusStr.substr(1);
	}
	
	var rows = $('#device-info-datagrid').datagrid('getRows');
	for(var i=0;i<rows.length;i++){
		var row=rows[i];
		if(row.deviceId==data.deviceId){
			$('#device-info-datagrid').datagrid('updateRow',{
				index: i,
				row: data
			});
			return;
		}
	}
	
	if(rows.length>49){
		('#device-info-datagrid').datagrid('deleteRow',rows.length-1);
	}
	
	$('#device-info-datagrid').datagrid('insertRow',{  
	     index : 0,  
	     row : data
	});
}

function startDwr(){
	//轮询模式与comet模式的反向Ajax所需要的配置 
	//dwr.engine.setActiveReverseAjax(true);  
	 
	//重点关于解决页面每刷新一次会多创建一个新的ScriptSession的解决方法  
	//由于ScriptSession的创建机制不同于HttpSession，它会在每次页面刷新的时候都会重新创建，而销毁机制却是失去连接  
	//或者失效之后一定时间才会自动销毁，这样就可能造成服务端可能就保存了很多的无用的ScriptSession,所以不仅仅会影响  
	//性能问题，更重要的是，可能就不能实现你想要的功能。  
	//解决方法是在接收消息的页面，也就是你调用dwr.engine.setActiveReverseAjax(true);的页面调用一个dwr的方法。  
	//dwr.engine.setNotifyServerOnPageUnload(true);  
	//这个方法的功能就是在销毁或刷新页面时销毁当前ScriptSession，这样就保证了服务端获取的ScriptSession集合中没有  
	//无效的ScriptSession对象。  
	dwr.engine.setActiveReverseAjax(true);
	dwr.engine.setNotifyServerOnPageUnload(true); 
	dwr.engine.setErrorHandler(dwrErrorHandler);
	//根据业务设置过滤条件
	DWRMessagePusher.init();  
} 

function dwrErrorHandler(errorMessage, exception){  
	startDwr();
} 

function handleDwrPushMsg(msg){
	var message = JSON.parse(msg); 
	var messageBody=message.message;
	if(message.type==1){
		//车辆上下线
		onlineMessageHandler(messageBody);
	} else if(message.type==2){
		//车辆告警信息
		setDeviceAlarmInfo(messageBody);
	}else if(message.type==4){
		//网关重启
		gatewayRestartMessageHandler(messageBody);
	}else if(message.type==5){
		//流量异常告警
		setDataLimitAlarmInfo(messageBody);
	}else if(message.type==9){
		//多媒体信息
		setTimeout(function(){
			mediaMessageHandler(messageBody);
		},2*1000);
	}
	
}

function onlineMessageHandler(messageBody){
	var title="设备上下线提示";
	var online=(messageBody.state==1?"上线":"下线");
	var content=messageBody.deviceName+online;
	showTipMessage(title,content);
}

function showAlarmTipMessage(deviceName,alarmInfo){
	var title=deviceName+"告警提示";
	showTipMessage(title,alarmInfo);
}

function gatewayRestartMessageHandler(messageBody){
	var title="网关重启提示";
	var content="网关重启";
	showTipMessage(title,content);
}

function mediaMessageHandler(messageBody){
	if(messageBody.mediaType==0){
		var mediaUrl=getContextPath()+"/media/downloadMedia.do?url="+message_api_server_servlet_path+"/deviceUpMediaData/"+messageBody.id+".json";
		var title=messageBody.deviceName;
		showImg(mediaUrl,title);
	}
}

var current_selected_device =null;
function onSelectDevice(id){
	var url=management_api_server_servlet_path+"/common/device/"+id+".json";
	var data={}
	ajaxAsyncGet(url,data,function(result){
		result=result.data;
		current_selected_device=result;
		if(current_device_marker){
			mapUtil.removeOverlay(current_device_marker);
			current_device_marker=null;
		}
		points=null;
		current_selected_device_lacation=null;
		current_selected_device_gps=null;
		cleanSearchAreaDevicesResults();
		getLastGps(id);
	});
}

function getLastGps(id){
	var url=lbs_api_server_servlet_path+"/gps/"+id+"/last.json";
	var data={}
	ajaxAsyncGet(url,data,getLastGpsResultHandler);
}

var current_device_marker;
var points;
var current_selected_device_lacation;
var current_selected_device_gps;
function getLastGpsResultHandler(result){
	if(!result || !result.data){
		return;
	}
	result=result.data
	current_selected_device_gps=result;
    var gcj02 = LngLatConverter.wgs84togcj02(result.lng,result.lat);
	var point=mapUtil.getPoint(gcj02[0],gcj02[1]);
	current_selected_device_lacation=point;
	if(points==null){
		points=new Array();
		points[0]=point;
	}else{
		if(points.length>1) points[0]=points[1];
		points[1]=point;
		//大于2公里不划线
		if(mapUtil.getDistance(points[0],points[1])>2*1000){
			points[0]=points[1];
		}
	}
	if(current_device_marker==null){
		addDeviceMarker();
	}else{
		mapUtil.setMarkerPosition(current_device_marker,point);
	}
	mapUtil.setMarkerRotation(current_device_marker,result.direction);
	//setMarkerLabel();
	var map=mapUtil.getMap();
	map.panTo(point);
	mapUtil.drawPolyline(points,"red");
	setDeviceInfo(current_selected_device,current_selected_device_gps);
}

function addDeviceMarker(){
	if(current_selected_device==null){
		return;
	}
	var iconUrl=current_selected_device.state == 2 ?"/images/gray_car.gif":"/images/yellow_car.gif";
	var name=current_selected_device.name;
	var direction = current_selected_device_gps.direction;
	current_device_marker=mapUtil.addMarker(current_selected_device.id,current_selected_device_lacation,name,iconUrl,direction);
	current_device_marker.on('click', function(e) {
		var deviceId=e.target.getExtData();
		var lacation=e.target.getPosition();
		showDeviceInfoWindow(lacation,deviceId);
    });
}

function initMap(){
	mapUtil.init("map");
	
	var script = document.createElement("script");
	script.type = "text/javascript";
	script.src = "http://webapi.amap.com/ui/1.0/main.js?v=1.0.11";
	document.body.appendChild(script);
	//按行政区查车
	setTimeout("initDistrictSearch()",5*1000);
}

function initDistrictSearch(){
	mapUtil.getDistrictSearch().search("中国", function(status, result) {
		   if(status=="complete"){
			   //setDistrictSearchResult(result);
			   setDistrictRailSearchResult(result);
	       }
	});
}

var current_district_polygons=[];
function setDistrictSearchResult(result) {
	current_district_polygons=[];
	var district = result.districtList[0];
    var bounds = district.boundaries;
    var map = mapUtil.getMap();
    if (bounds) {
        for (var i = 0, l = bounds.length; i < l; i++) {
        	var polygon=mapUtil.addPolygon(bounds[i]);
            current_district_polygons.push(polygon);
        }
        map.setFitView();//地图自适应
    }
}

var current_dialog_id;
function openDialog(dialogId){
	if(current_selected_device){
		current_dialog_id = dialogId;
		$("#"+dialogId).dialog("open");
		$("#"+dialogId+"-frm-name").val(current_selected_device.name);
		$("#"+dialogId+"-frm-deviceId").val(current_selected_device.id);
	}else{
		showMessage("请选择要操作的设备！");
	}
}

function closeDialog(dialogId){
	$("#"+dialogId).dialog("close");
}

function clearOverlays(){
	mapUtil.clearOverlays();
	//重新添加选中的设备
	addDeviceMarker();
	//setMarkerLabel();
	if(pathSimplifierIns){
		pathSimplifierIns.clearPathNavigators();
		pathSimplifierIns.setData(null);
	}
}
var search_device_type = 1;
var search_device_circle;
function searchDeviceByRail(){
	cleanSearchDeviceDraw();
	showMessage("请在地图上画圆形区域查车！");
	mapUtil.closeDraw();
	mapUtil.openDraw();
	mapUtil.drawCircle(function(e, circle){
		circle=e.obj;
		search_device_circle=circle;
		var point=circle.getCenter();
		//国测局坐标转wgs84坐标
	    var wgs84 = LngLatConverter.gcj02towgs84(point.getLng(), point.getLat());
		var area={};
		area.radius=parseInt(circle.getRadius());
		area.lat=wgs84[1];
		area.lng=wgs84[0];
		mapUtil.closeDraw();
		var data={};
		data.type=1;
		data.area=area;
		search_device_type=1;
		var url=lbs_api_server_servlet_path+"/area/devices";
		ajaxAsyncPost(url,data,loadAreaDevicesResultHandler,true);
	});
}

function searchDeviceByRectangle(){
	cleanSearchDeviceDraw();
	showMessage("请在地图上画矩形区域查车！");
	mapUtil.closeDraw();
	mapUtil.openDraw();
	mapUtil.drawRectangle(searchDeviceDrawPolygonCompletedHandler);
}

function searchDeviceByPolygon(){
	cleanSearchDeviceDraw();
	showMessage("请在地图上画多边形区域查车！");
	mapUtil.closeDraw();
	mapUtil.openDraw();
	mapUtil.drawPolygon(searchDeviceDrawPolygonCompletedHandler);
}

function cleanSearchDeviceDraw(){
	for (var i = 0, l = current_district_polygons.length; i < l; i++) {
	    current_district_polygons[i].setMap(null);
	}
	if(search_device_circle){
		mapUtil.removeOverlay(search_device_circle);
	}
}

function searchDeviceDrawPolygonCompletedHandler(e, polygon){
	polygon=e.obj;
	current_district_polygons=[];
	current_district_polygons.push(polygon);
	var path=polygon.getPath();
	var points = "";
	//国测局坐标转wgs84坐标
	for(var i=0;i<path.length;i++){
		var point = path[i];
		var wgs84 = LngLatConverter.gcj02towgs84(point.getLng(), point.getLat());
		points+=";"+wgs84[0]+","+wgs84[1];
	}
	var area={};
	area.path=points.substr(1);
	var data={};
	data.type=2;
	data.area=area;
	search_device_type=2;
	var url=lbs_api_server_servlet_path+"/area/devices";
	ajaxAsyncPost(url,data,loadAreaDevicesResultHandler,true);
	mapUtil.closeDraw();
}

function searchDeviceByDistrict(){
	if(!current_search_district_area_code){
		showMessage("当前没有选中的区域，请重新选择区域！");
		return;
	}

	var data={};
	data.type=3;
	data.areaCode=current_search_district_area_code;
	search_device_type=2;
	var url=lbs_api_server_servlet_path+"/area/devices";
	ajaxAsyncPost(url,data,loadAreaDevicesResultHandler,true);
}

var current_search_district_area_code;
function searchDistrict(object,level){
	 //清除地图上所有覆盖物
    for (var i = 0, l = current_district_polygons.length; i < l; i++) {
    	current_district_polygons[i].setMap(null);
    }
    var areaCode = $(object).val();
    var district = mapUtil.getDistrictSearch();
    //district.setLevel(level); //行政区级别
    district.setSubdistrict(0);
    district.setExtensions("all");
    //行政区查询
    //按照adcode进行查询可以保证数据返回的唯一性
    district.search(areaCode, function(status, result) {
        if(status === 'complete'){
        	setDistrictSearchResult(result);
        }
    });
    current_search_district_area_code=areaCode;
    if(level!="biz_area"){
        loadDistrict(areaCode,level);
    }
}

var search_area_device_results=[];
function cleanSearchAreaDevicesResults(){
	for(var i=0,l=search_area_device_results.length; i<l; i++){
		mapUtil.removeOverlay(search_area_device_results[i]);
	}
	search_area_device_results=[];
}
function loadAreaDevicesResultHandler(result){
	cleanSearchAreaDevicesResults();
	if(!result || !result.data || result.data.length ==0){
		showMessage("该区域内无车辆！");
		return;
	}
	result=result.data;
	//超过50不在地图上面打点，数量太多，地图卡死
	var count = 0;
	for(var index=0,l=result.length; count < 50 && index < l; index++){
		var item = result[index];
		var deviceId=item.deviceId;
		var iconUrl=isOnline(deviceId)?"/images/yellow_car.gif":iconUrl="/images/gray_car.gif";
		//var gpsInfo = syncGetLastGps(deviceId);
		//if(!gpsInfo) continue;
	    var gcj02 = LngLatConverter.wgs84togcj02(item.lng,item.lat);
		var lacation=mapUtil.getPoint(gcj02[0],gcj02[1]);
		//如果是多边形区域，再次计算是否在区域内
		if(search_device_type==2 && current_district_polygons.length>0){
			var bool = false;
			for(var i=0;i<current_district_polygons.length;i++){
				if(current_district_polygons[i].contains(lacation)){
					bool=true;
					break;
				}
			}
			if(!bool){
				continue;
			}
		}else if(search_device_type==1 && search_device_circle){
			//如果是圆形区域，再次计算是否在区域内
			var point=search_device_circle.getCenter();
			var radius=search_device_circle.getRadius();
			if(point.distance(lacation)>radius){
				continue;
			}
		}
		count++;
		if(current_selected_device && current_selected_device.id==deviceId){
			continue;
		}
		var name =getDeviceName(deviceId);
		var direction = Math.floor(360/Math.floor(Math.random()*10+1));
		var marker=mapUtil.addMarker(deviceId,lacation,name,iconUrl,direction);
		search_area_device_results.push(marker);
		marker.on('click', function(e) {
			var deviceId=e.target.getExtData();
			var lacation=e.target.getPosition();
			showDeviceInfoWindow(lacation,deviceId);
	    });
	}
	if(count==50){
		showTipMessage("温馨提示","该区域内有"+result.length+"辆车，显示前50辆！");
	}else{
		showTipMessage("温馨提示","该区域内有"+count+"辆车！");
	}
}

function syncGetLastGps(deviceId){
	var url=lbs_api_server_servlet_path+"/gps/"+deviceId+"/last.json";
	var result = ajaxSyncGet(url,{});
	if(result.code==0){
		return result.data;
	}
	return null;
}

var show_device_infowindow_deviceId;
var show_device_infowindow_lacation;
function showDeviceInfoWindow(lacation,deviceId){
	show_device_infowindow_deviceId=deviceId;
	show_device_infowindow_lacation=lacation;
	mapUtil.regeocoder(lacation,function(address){
		var gpsInfo = syncGetLastGps(show_device_infowindow_deviceId);
		var text="<b>"+getDeviceName(show_device_infowindow_deviceId)+"</b> 速度："+parseInt(gpsInfo.speed)+"km/h";
		text+="<br/>时间："+new Date(gpsInfo.gpsTime).format();
		if(address!=""){
			text+="<br/>地址："+address;
		}
		// 设置label标签
		mapUtil.addLabel(show_device_infowindow_lacation,text);
	});
}

function loadDistrict(parentCode,level){
	var url=management_api_server_servlet_path + "/common/query/dictionary/district.json?select=code,name&countable=false&pageSize=1000&pageNo=1";
	var data={"parentCode.eq":parentCode};
	ajaxAsyncPost(url,data,function(result){
		if (result.code!=0) {
			showErrorMessage(result.message);
		}else{
			 var list=result.data;
			 var select;
	         if (level === 'province') {
	        	 $("#district-search-province").empty();
	        	 $("#district-search-city").empty();
	        	 $("#district-search-district").empty();
	        	 select = $("#district-search-province");
	         } else if (level === 'city') {
	        	 $("#district-search-city").empty();
	        	 $("#district-search-district").empty();
	        	 select = $("#district-search-city");
	         }else if(level === 'district'){
	        	 $("#district-search-district").empty();
	        	 select = $("#district-search-district");
	         }
	         select.append("<option value=''>--请选择--</option>");
	         for (var i = 0, l = list.length; i < l; i++) {
	        	 var arr = list[i];
	        	 select.append("<option value='"+arr[0]+"'>"+arr[1]+"</option>");
	         }
		}
	});
}
</script>